问题
One of the parameters in my Jenkins
build is an Extended Choice Parameter which is submitted as a selection of comma separated values when invoking the build from the build webpage.
However, I also need to invoke the build using wget
+ URL
.
So, in the format:
wget "${JENKINS_URL}/job/buildname/buildWithParameters?ECP_LIST=blah1&token=token"
Say my Extended Choice Parameter ECP_LIST has possible values: blah1, blah2, blah3, blah4.
if I invoke, for example:
wget "${JENKINS_URL}/job/buildname/buildWithParameters?ECP_LIST=blah3&token=token"
the build starts fine with value blah3 for the EPC_LIST parameter.
However, if I wish to invoke it with 2 or more values, it just passes a blank value to the parameter.
I've tried separating the values using various things, like spaces, encoded comma, semi-colon. I haven't had any luck finding an answer here or on Google either.
回答1:
Including the URL in single quotes work:
wget '${JENKINS_URL}/job/buildname/buildWithParameters?ECP_LIST=blah3&token=token'
Similarly if you want to run a curl through your Jenkins API with curl you would run:
curl -X POST 'http://api:xxxxxxxxxxxxxxxxxxxxxxx@jenkins.YOURSERVER.com/job/BUILDNAME/buildWithParameters?parameter2=blah¶meter2=blahblah'
回答2:
I did solve it by selecting ECP_LIST
multiple times:
wget "${JENKINS_URL}/job/buildname/buildWithParameters?ECP_LIST=blah1&ECP_LIST=blah2&ECP_LIST=blah3&token=token"
Will result in:
ECP_LIST=blah1,blah2,blah3
I hope that works for you.
回答3:
You need to encode your URL before you pass it to wget I think, if your parameters contain special chars. I do it like this in python. I use curl.
url_params = {'param1' : param_value1, 'param2' : param_value2}
params_encoded = urllib.urlencode(url_params)
params = ['curl.exe', '-v', '-X', 'POST', '--show-error', '%s?%s' % (JobUrl), params_encoded]
subprocess.check_call(params)
回答4:
This works for me!
curl -X POST -u "username:password" '${JENKINS_URL}/job/buildnamebuildWithParameters?para1=value¶2=value'
来源:https://stackoverflow.com/questions/22607368/jenkins-pass-multiple-extended-choice-parameter-values-using-a-url