Skip to content

Instantly share code, notes, and snippets.

@alekpopovic
Forked from JonathanTurnock/README.md
Created October 4, 2024 21:14
Show Gist options
  • Save alekpopovic/cf5f24a220f948fd8c62c394b738a19b to your computer and use it in GitHub Desktop.
Save alekpopovic/cf5f24a220f948fd8c62c394b738a19b 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