Jenkins: pass multiple values ​​of advanced selection parameter using url

One of the options in my Jenkins assembly is an advanced selection parameter, which appears as a choice of comma separated values ​​when invoking the assembly from the assembly web page.

However, I also need to call the assembly using wget + URL .

So, in the format:

 wget "${JENKINS_URL}/job/buildname/buildWithParameters?ECP_LIST=blah1&token=token" 

Say that my advanced selection parameter ECP_LIST has possible values: blah1, blah2, blah3, blah4.

if I call for example:

 wget "${JENKINS_URL}/job/buildname/buildWithParameters?ECP_LIST=blah3&token=token" 

build starts normally with blah3 for parameter EPC_LIST.

However, if I want to call it with 2 or more values, it just passes an empty value to the parameter.

I tried to separate the values ​​using different things like spaces, encoded comma, semicolon. I’m not lucky to find the answer here or on Google.

+7
jenkins
source share
4 answers

Enclosing the URL in single quotes:

 wget '${JENKINS_URL}/job/buildname/buildWithParameters?ECP_LIST=blah3&token=token' 

Similarly, if you want to run curl through your Jenkins API using curl, you can run:

 curl -X POST 'http://api: xxxxxxxxxxxxxxxxxxxxxxx@jenkins.YOURSERVER.com /job/BUILDNAME/buildWithParameters?parameter2=blah&parameter2=blahblah' 
+2
source share

I resolved it by selecting ECP_LIST several 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 this works for you.

+3
source share

You need to encode the URL before passing it to wget, I think if your parameters contain special characters. 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) 
0
source share

It works for me!

 curl -X POST -u "username:password" '${JENKINS_URL}/job/buildnamebuildWithParameters?para1=value&para2=value' 
0
source share

All Articles