暂时在System Groovy中的Jenkins服务器上禁用SCM轮询 [英] Temporarily disable SCM polling on Jenkins Server in System Groovy

查看:101
本文介绍了暂时在System Groovy中的Jenkins服务器上禁用SCM轮询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一台Jenkins服务器,它在20到30个作业之间运行.

We have a Jenkins server which is running somewhere between 20 and 30 jobs.

由于构建过程相当复杂,因此我们将实际构建细分为1个子构建,其中一些可以同时运行,而另一些则必须遵循先前的构建步骤.因此,我们将每个构建步骤分为3个组,在构建过程进行时会阻塞.

Since the build process is reasonably complex we're broken the actual build down into 1 sub-builds, some of which can run concurrently, others have to follow previous build steps. As a result we've grouped each of the build steps into 3 groups, which block while the builds are in pogress.

例如:

Main Build : GroupA  : Builds A1, A2 & A3

           : GroupB  : Builds B1, B2 & B3

           : GroupC  : Builds C1, C2, C3, C4, C5 & C6

           : GroupD  : HW_Tests T1, T2, T3, T4 & T5


Builds B1, B2 & B3 rely on the output from A1, A2, A3 etc

由于有几乎每天24/7都运行的构建和测试,所以我发现很难安排Jenkins Master的重启.选择准备关闭"将意味着新作业已排队,但将始终阻止正在运行的作业,因为在上面的示例中,如果GroupB处于活动状态,则版本C1,C2等也将排队,并且主版本将被封锁.

Since there are builds and tests running pretty much 24/7, I am finding it difficult to schedule a restart of the Jenkins Master. Choosing "Prepare for shutdown" will mean new jobs are queued, but it will invariably block a running job since, to use my example above, if GroupB is active, builds C1, C2, etc will be queued also, and the Main Build will be blocked.

作为一种变通办法,我想在所有正在运行的作业完成之前在服务器上禁用SCM轮询.这样可以防止触发新作业,但也可以完成正在运行的作业.然后,我可以重新启动Jenkins并重新启用SCM轮询,以恢复正常服务.

As a work around, I would like to disable the SCM polling on the server until all running jobs have finished. This will prevent new jobs from triggering but also allow the running jobs to finish. I can then restart Jenkins and , re-enable SCM polling, allowing normal service to resume.

我们正在使用的SCM是Perforce.

The SCM we are using is Perforce.

我无法找到任何表明上述可能性的地方,但是,我确信它在System Groovy中必须是可行的……只是不确定如何做到.请问有人在这里有什么想法吗?

I have not been able to find anywhere which suggests the above is possible, however, I am sure it must be feasible in System Groovy ... just not sure how. Does anyone here have any ideas please?

非常感谢

推荐答案

您可以仅禁用具有SCM轮询触发器的那些作业.这个普通的脚本可以做到这一点:

You could disable only those jobs which have an SCM polling trigger. This groovy script will do that:

Hudson.instance.items.each { job ->
  if ( job.getTrigger(  hudson.triggers.SCMTrigger ) != null ) {
    println "will disable job ${job.name}"
    job.disable()
  }
}

重新启用作业将作为练习:)

Re-enabling the jobs will be left as an exercise : )

这篇关于暂时在System Groovy中的Jenkins服务器上禁用SCM轮询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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