Created
July 27, 2016 05:00
-
-
Save adampats/b0c37de0f684e14c5897ddf1cb889f63 to your computer and use it in GitHub Desktop.
Jenkins Credentials Binding pipeline groovy
This file contains 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
try { | |
err = null | |
currentBuild.result = "SUCCESS" | |
node { | |
stage 'One' | |
// using a single secret Jenkins credential | |
withCredentials([[$class: 'StringBinding', credentialsId: 'my-api-token', variable: 'API_TOKEN']]) { | |
sh ''' | |
set +x | |
echo '$API_TOKEN (should be masked by Jenkins UI as ***): ' "$API_TOKEN" | |
''' | |
} | |
} | |
} catch (caughtError) { | |
err = caughtError | |
currentBuild.result = "FAILURE" | |
} finally { | |
if (err) { | |
throw err | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment