首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >取消命令行中的Jenkins作业(CLI)

取消命令行中的Jenkins作业(CLI)
EN

Stack Overflow用户
提问于 2015-11-27 01:52:05
回答 3查看 10.3K关注 0票数 2

就像使用“build”命令从Jenkins启动作业一样,是否有一种方法可以使用CLI或任何其他命令行技术取消长期运行的作业。这是我在windows机器上尝试的,我不想直接杀死任务管理器中的进程,也不想关闭jenkins。请建议一下。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-11-29 13:26:13

您可以通过调用JOB_URL/lastBuild/stop来停止Jenkins执行

票数 3
EN

Stack Overflow用户

发布于 2015-11-27 22:04:51

Jenkins内置命令行工具不提供取消/停止/中止正在运行的构建的方法。但幸运的是,jenkins提供了其他脚本API,如、Python、Ruby ,它们具有这样的能力。

Python

类jenkinsapi.build.Build(url,buildno,job,depth=1)

代码语言:javascript
运行
AI代码解释
复制
stop()  
Stops the build execution if it’s running :
return boolean True if succeded    
False otherwise or the build is not running

API:https://jenkinsapi.readthedocs.org/en/latest/build.html

Ruby

类: JenkinsApi::Client::Job

代码语言:javascript
运行
AI代码解释
复制
#stop_build(job_name, build_number = 0)Object (also: #stop, #abort)
Stops a running build of a job This method will stop the current/most recent build if no build number is specified.

API:client/1.4.2/JenkinsApi/Client/Job

票数 0
EN

Stack Overflow用户

发布于 2019-10-24 10:34:28

此选项假定您可以访问Jenkins安装。

在Jenkins >2.195中,您可以使用Jenkins完成此操作:

代码语言:javascript
运行
AI代码解释
复制
# Export JENKINS_URL or add -s http://localhost[:port]/path/to/jenkins to the commands
export JENKINS_URL=http://localhost:8080/jenkins

# Get the name of the job you want to cancel
java -jar /path/to/jenkins-cli.jar -auth user:secret list-jobs

# Cancel the job
java -jar /path/to/jenkins-cli.jar -auth user:secret stop_builds <job_name>

# You can also disable the job, if needed
java -jar /path/to/jenkins-cli.jar -auth user:secret disable_job <job_name>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33954664

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档