Skip to content

Instantly share code, notes, and snippets.

@m-x-k
Created November 18, 2016 15:36
Show Gist options
  • Save m-x-k/a2193e3c42b4a31e64c7ba3db0e6fa92 to your computer and use it in GitHub Desktop.
Save m-x-k/a2193e3c42b4a31e64c7ba3db0e6fa92 to your computer and use it in GitHub Desktop.
Jenkins Pipeline sample using Credentials Binding Plugin
node {
stage('GetUserCredential') {
// Requires Credential setup (MyCredentialID)
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'MyCredentialID',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh '''
set +x
echo "$USERNAME" > output.txt
'''
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment