Jason P
Jason P

Reputation: 53

Jenkins Workflow building a new job

I'm trying make a parameterized build of a new job from my existing job as follows:

I tried both ways:

build('NEXT-DEPLOY-JOB', PARAM_FROM_BUILD:'1.4', DEPLOYMENT_ENVIRONMENT: "QA")

and without paranthesis way:

build 'NEXT-DEPLOY-JOB', PARAM_FROM_BUILD:'1.4', DEPLOYMENT_ENVIRONMENT: "QA" 

However in both cases I receive such error:

java.lang.IllegalArgumentException: Expected named arguments but got [{PARAM_FROM_BUILD=1.4, DEPLOYMENT_ENVIRONMENT=QA4}, NEXT-DEPLOY-JOB]

Please tell me, what I am doing wrong here?

Upvotes: 3

Views: 2995

Answers (2)

Jayan
Jayan

Reputation: 18458

Try something like below( as I learnt from @Jesse Glick, it is deprecated..)

build job: 'NEXT-DEPLOY-JOB', parameters: [new hudson.model.StringParameterValue('PARAM_FROM_BUILD', '1.4'),
hudson.model.StringParameterValue('DEPLOYMENT_ENVIRONMENT', 'QA')
]

Upvotes: 1

Jesse Glick
Jesse Glick

Reputation: 25481

The syntax quoted by @Jayan will work, but is deprecated. (And the Workflow syntax has nothing to do with persistence of state.)

Use Snippet Generator to see an example of the right syntax, tailored to the parameter types expected by the particular downstream job you are triggering.

Upvotes: 3

Related Questions