Trigger parameterized build with curl and crumb

前端 未结 7 841

I\'ve seen similar posts to this on SO, but not quite exactly what I am trying to do (or at least no full examples of a command to run).

I am trying to remotely trig

7条回答
  •  北海茫月
    2020-12-03 01:52

    This is emphasis on @seeker 's answer.

    Pay extra attention to getting the crumb step

    As the other answers mentioned, the crumb you get may differ depending on the browser you use to browse to Jenkins, be it Chrome, Curl or WGet.

    But, and this is an important but, the crumb that I used for the CURL command is the one I got from the WGET command. It isn't the crumb I got from the CURL -X GET command.

    I am not clear on why this is the case, but like in @Seeker 's answer, this worked for me.

    I got different crumbs when

    1. Browsing to http://qajenkins:8080/crumbIssuer/api/xml

    2. Browsing to http://10.143.18.43:8080/crumbIssuer/api/xml (qajenkins = 10.143.18.43)

    3. Running

      curl -X WGET http://10.143.18.43:8080/crumbIssuer/api/xml

    4. Or running

      wget -q --auth-no-challenge --user raamee --password 12345678 --output-document - 'http://10.143.18.43:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)';echo

    In order to get the curl command

    curl -X POST -H "Jenkins-Crumb:2e03fc96f387abggga6581fe5883a14a" http://10.143.18.43:8080/view/Raamee_phase_2/job/test_remote_api_triggerring/buildWithParameters?token=MY_TOKEN --user "raamee:12345678"
    

    I used the crumb I got from the wget command, the 4th command.

提交回复
热议问题