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
| // Token/String | |
| println(com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl.class, Jenkins.instance, null, null).findAll {it.id == id}[0].secret.value) | |
| // SSH key | |
| println(com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.class, Jenkins.instance, null, null).findAll {it.id == id}[0].getPrivateKey()) | |
| // Username password | |
| println(com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials.class, Jenkins.instance, null, null).findAll {it.id == id}[0].username) | |
| println(com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials.class, Jenkins.instance, null, null).findAll {it.id == id}[0].password) |
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 org.sonatype.nexus.capability.CapabilityReference | |
| import org.sonatype.nexus.capability.CapabilityType | |
| import org.sonatype.nexus.internal.capability.DefaultCapabilityReference | |
| import org.sonatype.nexus.internal.capability.DefaultCapabilityRegistry | |
| import org.sonatype.nexus.security.realm.RealmManager | |
| // Remove proxy | |
| core.removeHTTPProxy() | |
| core.removeHTTPSProxy() |
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 org.sonatype.nexus.cleanup.storage.CleanupPolicyStorage | |
| import org.sonatype.nexus.cleanup.storage.CleanupPolicyComponent | |
| def isCleanupPolicyExists(String name) { | |
| def cleanupPolicyStorage = container.lookup(CleanupPolicyStorage.class.getName()) | |
| return cleanupPolicyStorage.exists(name) | |
| } | |
| def deleteCleanupPolicy(String name) { | |
| def cleanupPolicyStorage = container.lookup(CleanupPolicyStorage.class.getName()) |
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
| ZSH_THEME="flazz" | |
| export EDITOR=vim | |
| # Prompt config | |
| CARETCOLOR=magenta | |
| PROMPT='%{${fg[cyan]}%}%n@%m%{${fg_bold[magenta]}%}:%{$reset_color%}%3~%{$fg_bold[cyan]%}$(__git_ps1 " (%s)") %{${fg_bold[$CARETCOLOR]}%}$%{${reset_color}%} ' | |
| RPROMPT='%{$fg[white]%}[%?][%l][%*]%{$reset_color%}' | |
| GIT_PS1_SHOWUPSTREAM=verbose |
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
| def static isPluginVulnerable(name) { | |
| def plugins = [:] | |
| // Push all plugins from all update site | |
| jenkins.model.Jenkins.instance.updateCenter.sites.each {plugins += it.data.plugins} | |
| def plugin = plugins[name] | |
| // Ignore |
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
| println(jenkins.model.Jenkins.instance.pluginManager.activePlugins.sort().collect { plugin -> "${plugin.shortName}:${plugin.version}" }.sort().join("\n")) |
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.security.CryptoConfidentialKey | |
| import java.security.KeyPair | |
| import java.security.spec.X509EncodedKeySpec | |
| import java.security.spec.PKCS8EncodedKeySpec | |
| import org.bouncycastle.util.io.pem.PemObject | |
| import org.bouncycastle.util.io.pem.PemWriter | |
| import org.jenkinsci.main.modules.instance_identity.InstanceIdentity | |
| import org.jenkinsci.main.modules.instance_identity.pem.PEMHelper | |
| import org.apache.commons.io.FileUtils | |
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
| // Retrieve all workflows | |
| def workflows = jenkins.model.Jenkins.instance.getAllItems(org.jenkinsci.plugins.workflow.job.WorkflowJob) | |
| // Ensure to take only workflow having a parent project | |
| workflows.findAll{ isProject(it.getParent()) }.each { workflow -> | |
| def project = workflow.getParent() | |
| def latestBuild = workflow.getLastBuild() | |
| // Ensure we have a latest build |
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
| jenkins.model.Jenkins.instance.allItems.findAll { (it instanceof hudson.model.Job) }.each { item -> | |
| def nextBuildNumber = item.getNextBuildNumber() | |
| def build = item.getLastBuild() | |
| if (build != null) { | |
| def lastBuildNumber = build.getNumber() | |
| if (nextBuildNumber <= lastBuildNumber) { | |
| println("Detected previous build number '${nextBuildNumber}' is smaller than last build '${lastBuildNumber}' for job '${item.displayName}'.") | |
| nextBuildNumber = lastBuildNumber + 1 | |
| println("Performed update to '${nextBuildNumber}'") | |
| item.updateNextBuildNumber(nextBuildNumber) |
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
| def scannableItems = jenkins.model.Jenkins.instance.getAllItems(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) + | |
| jenkins.model.Jenkins.instance.getAllItems(jenkins.branch.OrganizationFolder) | |
| scannableItems.collect { jenkins.model.Jenkins.getInstance().getQueue().schedule(it, 0, null, null)}.each { waitingItem -> | |
| def future | |
| def result | |
| try { | |
| future = waitingItem.getFuture() | |
| result = future.get(timeout, TimeUnit.SECONDS) | |
| println("${result} : ${result.getResult()}. Took ${result.getEstimatedDuration() / 1000.0} seconds") |