Skip to content

Instantly share code, notes, and snippets.

@kumbasar
Created August 9, 2018 08:19
Show Gist options
  • Save kumbasar/fde8a6748d089a5d0fe8d38dcc8ab7d3 to your computer and use it in GitHub Desktop.
Save kumbasar/fde8a6748d089a5d0fe8d38dcc8ab7d3 to your computer and use it in GitHub Desktop.
Get upstream info in downstream Jenkins job
node('myslave') {
stage('downstream') {
sh """
export shortDescription="${getCauser()?.shortDescription}"
export upstreamBuild="${getCauser()?.upstreamBuild}"
export upstreamUrl="${getCauser()?.upstreamUrl}"
export upstreamProject="${getCauser()?.upstreamProject}"
"""
}
}
@NonCPS
def getCauser() {
def upstream = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause)
return upstream
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment