How to stop a build in Jenkins via the REST api ?

前端 未结 4 1063
我寻月下人不归
我寻月下人不归 2020-12-01 08:08

I have a job in Jenkins. A website of our own triggers builds of this job via the REST api. Sometimes we want to abort the build. Sometimes, it can be before the build is ev

4条回答
  •  醉酒成梦
    2020-12-01 09:00

    Actually this question is already answered. So I will add, how to find id= , which I got stuck on finding this solution, which will helpful for others.

    So, you can get , by - http://jenkins:8081/queue/api/json

    Sample Output will be of json type like this one -

    [{"_class":"hudson.model.Cause$RemoteCause","shortDescription":"Started by remote host 172.18.0.2","addr":"172.18.0.2","note":null}]}],"blocked":false,"buildable":false,"id":117,"inQueueSince":16767552,"params":"\nakey\t=AKIQ\nskey=1bP0RuNkr19vGze/bcb4ijDqVr8o\nnameofr=us\noutputtype=json\noid=284102\nadminname=admin","stuck":false,"task"
    

    You have to take "id":117, and parse it to - queueItem =117.

    http:///queue/cancelItem?id=queueItem
    

提交回复
热议问题