Skip to content

Instantly share code, notes, and snippets.

@AlexChesters
Created July 13, 2017 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexChesters/48c1b4cf50a5fe2c46538d7526fceb71 to your computer and use it in GitHub Desktop.
Save AlexChesters/48c1b4cf50a5fe2c46538d7526fceb71 to your computer and use it in GitHub Desktop.
An example of using script block in a Declarative Jenkins Pipeline
stage('Set the build display name') {
steps {
script {
CURRENT_BRANCH = sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim()
CURRENT_HASH = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
currentBuild.displayName = "$CURRENT_BRANCH - $CURRENT_HASH"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment