Jenkins Pipeline: Build using parameters

0 votes

I'm trying to execute an existing job ('jenkins-test-project-build') using the build method with Jenkins pipeline.

 build('jenkins-test-project-build', param1 : 'some-value')

When I try to execute this I get te following error:

java.lang.IllegalArgumentException: Expected named arguments but got [{param1=some-value}, jenkins-test-project-build]
at org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:442)
at org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:380)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:156)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
...

Jul 10, 2018 in Jenkins by Tyrion anex
• 8,310 points
2,025 views

2 answers to this question.

0 votes

This error occurs because you havent passed the name of the attribute which should store 'jenkins-test-project-build'.

In your case you should pass job attribute,

build(job: 'jenkins-test-project-build', param1 : 'some-value')
answered Jul 10, 2018 by Sophie may
• 9,870 points
0 votes

First, as @sophie may mentioned it you should name your parameters if you have more than one (you can forget to name it only if you only use the default parameter job, e.g. build 'my-simple-job-without-params').

The second problem is that you are not passing parameters correctly. To pass parameters to a downstream job, you should use the parameter named parameters and give it an array of objects that define each of your parameters, e.g. :

build job: 'jenkins-test-project-build', parameters: [[$class: 'StringParameterValue', name: 'param1', value: "some-value" ]]

Also, note that parenthesis are optional in a Groovy method call.

answered Aug 8 by Sirajul
• 41,000 points

Related Questions In Jenkins

0 votes
1 answer

Jenkins Pipeline using Openshift

Create a new service account in openshift ...READ MORE

answered Aug 8, 2018 in Jenkins by Kalgi
• 46,110 points
109 views
0 votes
1 answer

Program to execute Dockerfile using Jenkins declarative pipeline

Hey @Nishant, you can use something like ...READ MORE

answered Apr 15 in Jenkins by Kalgi
• 46,110 points
181 views
+1 vote
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
261 views
0 votes
1 answer
0 votes
1 answer

Jenkins: Build Pipeline Plugin Scheduled Trigger

This can be done by setting the ...READ MORE

answered Jul 10, 2018 in Jenkins by Sophie may
• 9,870 points
658 views
0 votes
2 answers

How to trigger a Jenkins pipeline A in another Jenkins pipeline B?

If you are talking about executing another ...READ MORE

answered Jul 31 in Jenkins by Sirajul
• 41,000 points
7,715 views