This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.model.Jenkins | |
import hudson.model.Job | |
def allJobs = Jenkins.instance.getAllItems(Job.class) | |
def jobTypes = allJobs.collect { it.getClass().getName() }.unique() | |
jobTypes.sort().each { | |
println(it) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.cloudbees.plugins.credentials.* | |
import com.cloudbees.plugins.credentials.domains.Domain | |
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials | |
import groovy.json.JsonOutput | |
String filterCredentialId = null // Use null to list all credentials | |
def credsMap = [:] | |
CredentialsProvider.lookupStores(Jenkins.instance).each { store -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.cloudbees.plugins.credentials.* | |
import com.cloudbees.plugins.credentials.domains.Domain | |
import com.cloudbees.plugins.credentials.impl.* | |
import org.jenkinsci.plugins.plaincredentials.impl.* | |
import hudson.util.Secret | |
import groovy.json.JsonSlurper | |
def updateCredentials(String jsonData) { | |
def jsonSlurper = new JsonSlurper() | |
def credentialsToUpdate = jsonSlurper.parseText(jsonData) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get domains on /folder1 of local Jenkins | |
curl -s -g -u foo:<your_api_key_that_you_know_for_sure_works> \ | |
'http://localhost:8080/job/folder1/credentials/store/folder/api/json?tree=domains'|jq | |
# Get all attributes of the domains on /folder1 of local Jenkins | |
curl -s -g -u foo:<api-token> 'http://localhost:8080/job/folder1/credentials/store/folder/api/json?tree=domains[*]'|jq | |
{ | |
"_class": "com.cloudbees.hudson.plugins.folder.properties.FolderCredentialsProvider$FolderCredentialsProperty$CredentialsStoreActionImpl", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
from urllib.parse import urljoin | |
from pathlib import Path | |
def download_jenkins_cli(jenkins_url): | |
# Jenkins CLI URL endpoint | |
cli_url = urljoin(jenkins_url, 'jnlpJars/jenkins-cli.jar') | |
# Define the installation path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: docker-dind-rootless | |
spec: | |
containers: | |
- name: docker-dind-rootless-container | |
image: your-custom-dind-rootless-image:latest | |
securityContext: | |
runAsUser: 1000 # Example UID, ensure this matches the UID in your Docker image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.cloudbees.plugins.credentials.* | |
import com.cloudbees.plugins.credentials.domains.Domain | |
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl | |
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials( | |
com.cloudbees.plugins.credentials.common.StandardCredentials.class, | |
Jenkins.instance, | |
null, | |
null | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.model.Jenkins | |
import java.net.URLClassLoader | |
def printClasspath(ClassLoader cl, int level = 0) { | |
if (cl in URLClassLoader) { | |
cl.getURLs().each { url -> | |
println "${' ' * level}${url}" | |
} | |
} | |
if (cl.parent) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test { | |
// delete old test reports | |
dependsOn cleanTest | |
// don't stop if tests fail | |
ignoreFailures = false | |
// minimize logging | |
testLogging.maxGranularity = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
if [[ $1 == 'docker' ]]; then | |
docker run --name jenkins-local \ | |
-p 8080:8080 \ | |
-p 50000:50000 \ | |
-v "${HOME}/.jenkins":/var/jenkins_home \ | |
-d jenkins/jenkins:lts | |
else | |
/usr/local/opt/openjdk@11/bin/java \ |