Created
March 29, 2012 02:34
-
-
Save chrix2/2232656 to your computer and use it in GitHub Desktop.
Get parent build Jenkins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myJob = hudson.model.Hudson.instance.getItem("My_Job") | |
def lastBuild = myJob.getLastBuild() | |
def cause = lastBuild.getCause(hudson.model.Cause$UpstreamCause) | |
def parentBuildNum = cause.upstreamBuild | |
def parentJobName = cause.upstreamProject | |
def parentJobUrl = cause.upstreamUrl | |
println(parentBuildNum) | |
println(parentJobName) | |
println(parentJobUrl) | |
def parentJob = hudson.model.Hudson.instance.getItem(parentJobName) | |
def parentBuild = parentJob.getBuildByNumber(parentBuildNum) | |
println(parentBuild.getNumber()) | |
println(parentBuild.getId()) | |
println(parentBuild.getUrl()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful for a build/deployment pipeline!