Passing choice parameter via url for building a parameterized job remotely

Viewed 1313

I am trying to build a parameterized Jenkins job remotely by passing the parameters through a url.

I tried doing a curl request with POST.

 http://user:passwd@jenkins_url/job/TestParameterizedBuild/buildWithParameters?string_param=abc123&bool_param=true&choice_param=Green&token=TOKEN_VAL

The string and boolean parameters get the correct values - abc123 and true respectively. But the choice parameter takes the value Red instead of Green. [The choices provided for choice_param field are - Red, Green, Blue, in that order]. I guess it is always taking the default. Am i passing the value to choice parameter choice_param wrongly?

3 Answers

Try to use curl and rebuild your current build command:

http://user:passwd@jenkins_url/job/TestParameterizedBuild/buildWithParameters?string_param=abc123&bool_param=true&choice_param=Green&token=TOKEN_VAL

into curl build command:

curl -X POST -u Login:Pass "http://jenkins_url/job/TestParameterizedBuild/buildWithParameters?string_param=abc123&bool_param=true&choice_param=Green&token=TOKEN_VAL"

Remember to put link into quotes ""! Without quotes you pass only first parameter and rest of parameters will have default values.

I found workaround - in case you are able to modify the Jenkins Job

All you need to do is to replace your "Choice Parameter" to type of "Extended Choice Parameter", definition for example:

enter image description here

By this definition, it will looks as Drop Down List, same like "Choice Parameter", but it should work the same like "String Parameter" For above parameter I used URL link to trigger a build:

http://illin123:8070/job/VAPP_BOUNCE/buildWithParameters?ACTION=ping

Try passing field (e.g. 1, 2, 3...) instead of passing choice parameter's actual value. Hope it helps.

Related