Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Remove un-needed hudson.model.


Code Block
import hudson.model.*

// Retrieve parameters of the current build
def build = Thread.currentThread().executable
def resolver = build.buildVariableResolver
def foo = resolver.resolve("FOO")
println "FOO=$foo"

// Start another job
def params = [
  new StringParameterValue('FOO', foo),
def job = hudson.model.Hudson.instance.getJob('MyJobName')
def future = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))
println 'Waiting for the build to complete...'
def anotherBuild = future.get()

// Do something with the output.
// On the contrary to Parameterized Trigger Plugin, you may now do something from that other build instance.
// Like the parsing the build log (see )
// You probably may also wish to update the current job's environment.
build.addAction(new ParametersAction(new StringParameterValue('BAR', '3')))