Label Parameter in Groovy Post Build

66 views
Skip to first unread message

capt edgar

unread,
Jul 11, 2015, 1:56:42 PM7/11/15
to jenkins...@googlegroups.com
Hi there

I'm running Jenkins version 1.565.2

I'm having a strange problem when dynamically triggering downstream projects

I have created a job 'Sports - Core - Scheduled' which accepts 2 parameters. 
One - called 'Stream' which is for our stream(Source Control stream). This is a choice parameter 
Two - called 'Product' which is for our products(that we build in our company). This is a Label parameter having 10 nodes(servers) associated to it. 

When i build this job manually, Jenkins recognises the Label parameter and automatically picks one of the free node from the label and everything works fine.

We have about 300 of these sort of jobs for various streams/products scenarios for which i'm writing a Groovy script which calls all these jobs to run dynamically but the following script below is failing to recognise the label parameter and actually assigning someother node which is not even associated with the 'product' label.

Any idea what i'm doing wrong or what do i need to do to ensure i can pass a label parameter successfully to the script below.

I'm a newbie but i can provide more details if need be.


import hudson.model.*;
import jenkins.model.*;
import jenkins.*;

// Core Test run
job = Hudson.instance.getJob('Sports - Core - Scheduled');
timer =60
time=1;
WholeParams = [
["Core-Test","Sports"]
 ]
for (i in WholeParams)
{
params = []
params += new hudson.model.StringParameterValue('Stream', i[0])
params += new hudson.model.StringParameterValue('Product', i[1])
            paramsAction = new hudson.model.ParametersAction(params)

cause = new hudson.model.Cause.UpstreamCause(manager.build)
causeAction = new hudson.model.CauseAction(cause)
manager.hudson.queue.schedule(job,time, causeAction, paramsAction);
time=time+timer;
}
Reply all
Reply to author
Forward
0 new messages