就像使用“build”命令从Jenkins启动作业一样,是否有一种方法可以使用CLI或任何其他命令行技术取消长期运行的作业。这是我在windows机器上尝试的,我不想直接杀死任务管理器中的进程,也不想关闭jenkins。请建议一下。
发布于 2015-11-29 13:26:13
您可以通过调用JOB_URL/lastBuild/stop来停止Jenkins执行
发布于 2015-11-27 22:04:51
Jenkins内置命令行工具不提供取消/停止/中止正在运行的构建的方法。但幸运的是,jenkins提供了其他脚本API,如、Python、和Ruby ,它们具有这样的能力。
Python
类jenkinsapi.build.Build(url,buildno,job,depth=1)
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
#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.
发布于 2019-10-24 10:34:28
此选项假定您可以访问Jenkins安装。
在Jenkins >2.195中,您可以使用Jenkins完成此操作:
# 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>
https://stackoverflow.com/questions/33954664
复制相似问题