如何通过 REST api 在 Jenkins 中停止构建? [英] How to stop a build in Jenkins via the REST api ?

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

问题描述

我在詹金斯有一份工作.我们自己的网站通过 REST api 触发此作业的构建.有时我们想中止构建.有时,甚至可能在构建开始之前.在这种情况下,我们使用 queueItem # 而不是 build #.

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 on:

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>

这是假设你的 Jenkins 服务器没有受到保护,否则你需要添加 基本身份验证.

This is assuming your Jenkins Server has not been secured, otherwise you need to add BASIC authentication for a user with Cancel privileges.

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

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