Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ygor-glaboo/ed7443686f7e0ed33aebbbdc15e15d9a to your computer and use it in GitHub Desktop.
Save ygor-glaboo/ed7443686f7e0ed33aebbbdc15e15d9a to your computer and use it in GitHub Desktop.
Exporting short git commit sha1 hash in Jenkins through System Groovy Script build step
import hudson.model.*
def env = build.getEnvironment()
def gitCommit = env['GIT_COMMIT']
def shortGitCommit = gitCommit[0..6]
def pa = new ParametersAction([
new StringParameterValue("SHORT_GIT_COMMIT", shortGitCommit)
])
// add variable to current job
build.addAction(pa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment