You might want to use Groovy System Script to process those parameters (note that /System/ script is not an OS script, it's Jenkins script). It will be much easier to process strings in it.

Here is something to get you started. This is a script that schedules "Some-job-name" to be run with some parameters. If you use string parameters you might want to trim and validate values passed by users to avoid some security/consistency problems.

// start
//--------------------------
import hudson.model.*

//
// run
//
def appServersString = 
build.buildVariableResolver.resolve("parameterOfCurrentJob")
def appServersList = appServersString.split(',')
for (appServer in appServersList) {
  scheduleAppRollout(appServer)
}

/**
        Schedule rollout helper
*/
def scheduleAppRollout(dstServer) {
  def job = Hudson.instance.getJob("Some-job-name")

  // prepare parameters
  def params = []
  params += new StringParameterValue('dstServer', dstServer)
  params += new BooleanParameterValue('somBooleanParamOfTheJobToBeStarted', 
true)
  params += new BooleanParameterValue('imABot', true)
  def paramsAction = new ParametersAction(params)

  //preapre cause
  def cause = new Cause.UpstreamCause(build)
  def causeAction = new CauseAction(cause)

  // run
  println("[INFO] Scheduling rollout to `" + dstServer + "`");
  Hudson.instance.queue.schedule(job, 0, causeAction, paramsAction)
}
//--------------------------
// EOF

--
You received this message because you are subscribed to the Google Groups "Jenkins 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/22393ccf-5398-d10f-80c8-9f49e42b6a33%40mol.com.pl.
For more options, visit https://groups.google.com/d/optout.

Reply via email to