Created
February 7, 2017 15:34
-
-
Save robmaidment/64c5bcdf8808f0c42947a4a78ed1ee2c to your computer and use it in GitHub Desktop.
Using a Jenkins system groovy script to trigger another job, based on an input parameter
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
import jenkins.* | |
import jenkins.model.* | |
import hudson.* | |
import hudson.model.* | |
def SELECTED_JOB = build.buildVariableResolver.resolve("SELECTED_JOB") | |
def target = Jenkins.instance | |
.getItemByFullName(SELECTED_JOB) ?: null | |
if (!target) { | |
println "No downstream job found" | |
} else { | |
println "I found it!" | |
def execution = target.scheduleBuild2(0, new Cause.UpstreamCause(build)) | |
println "Running test job:" | |
println "Complete, result was: " + execution.get().result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment