Skip to content

Instantly share code, notes, and snippets.

@JonathanTurnock
Created October 19, 2020 09:53
Show Gist options
  • Save JonathanTurnock/1035f716aa8f3ccec886a9bf17df7218 to your computer and use it in GitHub Desktop.
Save JonathanTurnock/1035f716aa8f3ccec886a9bf17df7218 to your computer and use it in GitHub Desktop.
Get Current Jenkins Git Commit Hash

To Display the current git commit hash execute the following snipped:

git rev-parse --short HEAD

To Extract this to use in a Jenkinsfile use the sh function with the script and returnStdout parameter set to true:

def commitHash = sh(script: 'git rev-parse --short HEAD', returnStdout: true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment