从另一个工作中禁用Jenkins工作 [英] Disable Jenkins Job from Another Job

查看:114
本文介绍了从另一个工作中禁用Jenkins工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

詹金斯(哈德森)中是否有办法从另一个工作中禁用一个工作?

Is there a way in Jenkins (Hudson) to disable a job from another job?

基本上,我们有一个进行标准构建/测试的构建环境.我们还使用相同的Jenkins实例来执行其他一些操作,例如自动安装产品的新版本(某些自动化测试需要此功能).当我们运行某些额外"作业时,我们希望暂时禁用标准"作业(然后在以后自动启用它们).

Basically we have a build environment that does the standard building/testing. We also use the same Jenkins instance to do some other stuff like install new versions of our product automatically (which is needed for some of the automated tests). When we are running some of the "extra" jobs, we want to disable the "standard" jobs temporarily (and then automatically enable them later).

理想情况下,作业上会有一些额外的构建步骤,例如禁用XYZ作业".或者,如果有办法通过ANT或让Jenkins禁用某项工作,那也可以.

Ideally there would be some extra build step on a job to say "Disable XYZ job". Or if there is a way through ANT or something to tell Jenkins to disable a job, that would work too.

更新: 看来有几个插件可以阻止两个作业同时运行,但我确实需要:

Update: It looks like there are a couple plugins that will prevent two jobs from running at the same time, but I really need to:

  1. 运行作业A,该作业将禁用作业1
  2. 根据作业A的输出在Jenkins之外做一些事情
  3. 运行作业B,它再次启用作业1

推荐答案

我发现了使用jenkins-cli(命令行界面)的一种可能方法.我添加了此构建步骤(对我来说,这是一个Windows批处理命令,尽管我可以将其设置为脚本或更精致的名称):

I found one possible approach using the jenkins-cli (command-line interface). I added this build step (for me it was a Windows batch command, though I may make it a script or something more elegant):

java -jar C:\my\jenkins\path\jenkins-cli.jar -s %JENKINS_URL% disable-job "Job 1"

我还没有研究如何获得通往詹金斯的道路,但这应该不会太困难.

I haven't looked into how to get the path to Jenkins, but that should not be too hard.

以下是 CLI上的信息.您也可以访问 http://your-jenkins:8080/cli 以获得一些可用的命令.

Here is some information on the CLI. You can also go to http://your-jenkins:8080/cli for some of the available commands.

这篇关于从另一个工作中禁用Jenkins工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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