Search code examples
jenkinsjenkins-plugins

How to block a Jenkins job from running at certain times


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.


Solution

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

    Something like that:

    enter image description here