Parameterized build, REST, one parameter with new value rest with default

15 views
Skip to first unread message

Daniel Olausson

unread,
Aug 15, 2016, 2:53:44 AM8/15/16
to Jenkins Users
Hi,

I have a job that I would like to trigger via REST where I have one parameter that I want to change every time and the other ones I would like to use the default values for. If I do a POST to /build it just ignores the default values and set them to empty. If I do a post to /buildWithParameters I can't set the new value for the parameter I want, the default values for all parameters are taken.

How can I achieve this? First do a GET to get the default values, and then do a POST to /build with all the parameters even if they are just the default? 

thomas....@teamaol.com

unread,
Aug 15, 2016, 6:17:13 AM8/15/16
to Jenkins Users
Yes, basically you could retrieve the job XML parsing for the parameter definitions storing the default values and
then changing the values you want. Your function could also stop if not all mandatory fields are set.

I wrote my own jenkins controller (cannot publish the moment) but that one is not bad: https://github.com/txels/autojenkins
However one important feature is missing: https://github.com/txels/autojenkins/issues/30 (CSRF protection)

Regards,
Thomas

Daniel Olausson

unread,
Aug 15, 2016, 7:19:27 AM8/15/16
to Jenkins Users
Hi,

Yes that is basically what I did. Queried the ../api/json?tree=... URL. Then parsed the output and then did the post.

/Daniel

Reply all
Reply to author
Forward
0 new messages