how to cancel build queue jobs in jenkins, which are not started by jenkins and are in its build queue through REST API

ε祈祈猫儿з 提交于 2019-12-06 09:17:08

问题


how to cancel build queue jobs in jenkins through REST API, which are not started by jenkins and are in its build queue. I know how to cancel the in-progress job with below command

curl -X POST <jenkins-server>/job/<job-name>/<build-number>/doDelete                        

回答1:


To cancel a job in the queue, you can POST:

http://jenkins/queue/cancelItem?id=x

To find x, you can parse the result of:

http://jenkins/queue/api/json?tree=items[id,task[name]]

To cancel a build that is in progress:

http://jenkins/job/<jobName>/y/stop

To find y, you can parse the result of:

http://jenkins/job/<jobName>/lastBuild/api/json?tree=building,number



回答2:


It's not possible to cancel a job by its build number, only through the job id:

curl -X POST 'http://jenkins/queue/cancelItem?id=85'


来源:https://stackoverflow.com/questions/34261464/how-to-cancel-build-queue-jobs-in-jenkins-which-are-not-started-by-jenkins-and

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