问题
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