如何通过REST API停止詹金斯构建? [英] How to stop a build in Jenkins via the REST api ?

查看:120
本文介绍了如何通过REST API停止詹金斯构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在詹金斯的工作。我们自己的触发器的网站建设通过REST API这份工作。有时候,我们希望中止构建。有时,也可以是构建甚至开始之前。在这种情况下,我们有queueItem#,而不是构建#。

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 even started. In such cases we have the queueItem # instead of the build #.

如何通过REST API这样做呢?

How to do so via the REST api ?

推荐答案

如果构建已经开始,由 POST

If the build has started, by POST on:

http://<Jenkins_URL>/job/<Job_Name>/<Build_Number>/stop

将停止/取消当前的版本。

Will stop/cancel the current build.

如果构建还没有开始,你有 queueItem ,那么 POST

If the build has not started, you have the queueItem, then POST on:

http://<Jenkins_URL>/queue/cancelItem?id=<queueItem>

假设你的詹金斯还没有得到保证,否则,你需要添加?记号=记号来的网址,年底,其中 TOKEN 可与足够权限的用户的安全令牌取消的基础之上。

Assume your Jenkins has not been secured, otherwise you need to add ?token=TOKEN to the end of the urls, where TOKEN can be the security token of a user with sufficient privileges to cancel builds.

这篇关于如何通过REST API停止詹金斯构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆