I try to launch
curl -X POST -u "user:pass" -H Jenkins-Crumb:thecrumbnumber http://myjenkinsserver/jenkins/job/testjob/buildWithParameters?=PARAMETER=somenumber
which works by triggering a parametrized build, but the problem is no value is passed to the build (whats weird even when the token is set in the job, I can trigger the job without it). In jenkins, that job has a configured string "PARAMETER" with or without some default value, but never the parameter from the curl launch is passed. What I may be missing?
I'm using:
curl -X POST -u "user" "http://myjenkins/path/to/my/job/buildWithParameters?GERRIT_REFNAME=feature/retry&goal=package"
here and it's working like a charm.
Watch out the "=" in front of the "PARAMETER" in the URL you pasted.
Please try something like:
curl -X POST http://<jenkins URL>/jenkins/job/TESTS/job/<Your job's Name>/buildWithParameters \
--user <Jenkins account>:<account's TokenID> \
--data token=<job's token (if required)> \
--data parameter=some_value
...
--data MessageTextParameter=My%20Text
I used below command to pass Multiple parameter.
curl -X POST "https://myjenkins.com/job/jobname/buildWithParameters?token=developer&name=abc&userid=CFDH123&mail=abc@gmail.com"
Note: parameter names are case sensitive.
When I tried
curl -X POST http://icm.git:faedc992afcd1ea4db3da6809435117a@10.221.31.36:8080/job/1_TODO_Get_Submit_Request_With_Dependency_Test/buildWithParameters?PARAMETER=1494390553639
OR
curl -X POST -u "icm.git:lge123" -H Jenkins-Crumb:faedc992afcd1ea4db3da6809435117a http://10.221.31.36:8080/job/1_TODO_Get_Submit_Request_With_Dependency_Test/buildWithParameters?PARAMETER=1494390553639
Both triggered Jenkins Job > 1_TODO_Get_Submit_Request_With_Dependency_Test but the parameter in Jenkins log showed default value for parameter REQUESTID = -1
.
What is problem with Jenkins or CURL url ?
+ echo '4.2.25(1)-release'
4.2.25(1)-release
+ echo
+ echo 26
26
+ echo '#26'
#26
+ echo 1_TODO_Get_Submit_Request_With_Dependency_Test
1_TODO_Get_Submit_Request_With_Dependency_Test
+ echo 1_TODO_Get_Submit_Request_With_Dependency_Test
1_TODO_Get_Submit_Request_With_Dependency_Test
+ echo REQUESTID = -1
REQUESTID = -1
来源:https://stackoverflow.com/questions/42946863/passing-parameter-to-jenkins-job-through-curl-post-not-working