How to block a Jenkins job from running at certain times

一个人想着一个人 提交于 2019-12-10 17:42:54

问题


I have a Jenkins job which restarts our small in-house production system. It is fully automated, so when we check-in code changes, we run tests and other verification steps and finally automatically deploy the new version.

It is usually not a problem restarting the system as it will be back shortly and people are aware that there might be a small outage now and then.

However there are times during the day when I know that the system is heavily used and thus would like to prevent any automated restarts.

Is there a way to do this, e.g. configure a timeframe where a job is not running at all? I.e. something like "on weekdays from 8 to 10" or any other cron-based schedule.

The only option that I can think of is to periodically disable and enable the job via some cli-commands, but hopefully there is a better way to do this.


回答1:


You can use the Conditional BuildStep plugin and set some timeframe where your job can be launched (or not).

Something like that:




回答2:


You can also use Jenkins Curfew Plugin https://github.com/Jouda-Hidri/curfew
It helps you setup the timeframes throw the UI. You can do as following

Monday before 10, after 8
Tuesday before 10, after 8
etc.

the pipeline will abort during these times automatically.



来源:https://stackoverflow.com/questions/30799745/how-to-block-a-jenkins-job-from-running-at-certain-times

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!