passing parameter to jenkins job through curl POST not working?

≯℡__Kan透↙ 提交于 2019-12-22 06:36:32

问题


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?


回答1:


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.




回答2:


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



回答3:


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.




回答4:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!