How to disable a Jenkins job via curl?

前端 未结 5 1783
感动是毒
感动是毒 2020-12-10 02:24

I want to disable a Jenkins job by sending a post curl request to Jenkins.

I\'ve tried doing that using:

  1. curl -X POST http://:8080
5条回答
  •  臣服心动
    2020-12-10 02:54

    No valid crumb means your Jenkins installation has a security option enabled which prevent requests send in a standard way to avoid one-click attacks. You can't use Jenkins CLI either, because it doesn't work yet.

    Here are the steps using curl (replace localhost with your Jenkins address):

    1. Note your user API Token (from /user/USER/configure).
    2. Get your crumb:

      CRUMB=$(curl -s 'http://USER:TOKEN@localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
      
    3. Now you can disable the job by sending the crumb in the headers:

      curl -X POST -H "$CRUMB" http://USER:TOKEN@localhost:8080//disable
      

      If the above won't work for some reason, you may try to use -u USER:TOKEN instead.

提交回复
热议问题