Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: How can I make a remotely submitted job use default parameter values?

Tags:

jenkins

I am triggering a parametrized Jenkins job remotely using the Remote Access API like this:

url=http://<ci-host>/job/<jobname>/build
json="{\"parameter\": [{\"name\": \"A_NAME\", \"value\": \"a_value\"}]}"
curl -X POST $url -d token=zorn --data-urlencode json="$json"

I want Jenkins to use the configured default value for one of my parameters, but it seems to be expecting values for all of the parameters.

If I leave out a parameter, the job sees it as an empty string.

Is there a way to make it use the configured default value for a parameter?

EDIT: The solution (as per Daniel S.) was to use buildWithParameters as follows:

url=http://<ci-host>/job/<jobname>/buildWithParameters
curl -s -X POST $url

ANOTHER EDIT: But now the problem is that buildWithParameters does not work on a job with no parameters. So it cannot be used for a generic script to start all my jobs.

like image 707
Dawie Strauss Avatar asked Aug 08 '12 06:08

Dawie Strauss


People also ask

How do I invoke Jenkins job remotely?

Developers can follow these three steps to implement a remote Jenkins build trigger: Create a Jenkins build job and enable the Trigger builds remotely checkbox. Provide an authentication token; This can be any text string of your choice. Invoke the Jenkins build URL to remotely trigger the build job.

How do I use this project is parameterized in Jenkins?

Once you've created the build job, Jenkins will display the item's configuration page. On this configuration page, there is an unselected checkbox next to text that states: "This project is parameterized." Select this option, and in the drop-down that subsequently appears, choose the option to add a Boolean parameter.

Which command is used to trigger build remotely in Jenkins?

Configure a job to trigger from remote in Jenkins You can create a new FreeStyle job or you can use the previous one. Move to configuration -> Build Triggers sections and check the “Trigger builds remotely(e.g., from scripts)” option and paste the token name there.


1 Answers

Try to use buildWithParameters instead of build, i.e.

http://<ci-host>/job/<jobname>/buildWithParameters
like image 72
Daniel S. Avatar answered Oct 18 '22 21:10

Daniel S.