Last active
June 14, 2017 09:07
-
-
Save alces/f4baa2e1435bd8cac7a80ab654de8dce to your computer and use it in GitHub Desktop.
Schedule a build of a Jenkins job and print its URL after its start.
This file contains hidden or 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 hudson.model.* | |
// in order to pass environment variables into build, EnvInjectPlugin should be installed | |
import org.jenkinsci.plugins.envinject.EnvInjectPluginAction | |
println Hudson.instance.getItem('down_stream_job_name').scheduleBuild2( | |
5, // quiet period | |
new ParametersAction( // build parameters | |
new StringParameterValue('STR_PARAM', 'Its value'), // string parameter | |
new BooleanParameterValue('BOOL_PARAM', true) // boolean parameter | |
), | |
new EnvInjectPluginAction( // environment variables | |
ENV_VAR01: "I'm from upstream", | |
ENV_VAR02: "And I'm from there too" | |
) | |
).waitForStart().absoluteUrl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment