首页 > 解决方案 > Jenkins 自由式中止命令或步骤

问题描述

有谁知道中止 Jenkins Freestyle 工作的命令或步骤?

我可以在 3 分钟后使用超时,但无论如何我都看不到像管道作业一样通过设置currentBuild.result = 'ABORTED'.

我在 Windows 上运行 Jenkins,因此正在寻找 bat 命令或类似的解决方案。

标签: jenkinsjenkins-pipeline

解决方案


You can add "kill" to the end of the path of any running job's execution,

Ex: https://hostname/jenkins/job/DDNS/4902/kill

and it will take you to a page that says:

This URL requires POST

The URL you're trying to access requires that requests be sent using POST (like a form submission). The button below allows you to retry accessing this URL using POST. URL being accessed:

https://hostname/jenkins/job/DDNS/4902/kill

If you were sent here from an untrusted source, please proceed with caution.

There will be a button for "Retry Using POST" -- click that and it will automatically kill any running job, aborting at current stage.

Therefore, if you want to make a script, use that URL with some logic to land on the right job number, with a POST method, and it should do what you want.


推荐阅读