Is there an elegant way to temporarily prevent Jenkins from executing any further builds in a defined time frame (say e.g. daily between 6am and 7am)?
In order to prevent Jenkins from executing any jobs, you need to put it in "quiet down" mode when it starts up.
The Locks and Latches plugin should resolve your problem. Create a lock and have both jobs use the same lock. That will prevent the jobs from running concurrently. Install the plugin in "Manage Jenkins: Manage Plugins."
Rather than stopping Jenkins, you can put it into "Quiet Down" mode, which prevents any new builds from taking place.
You can enable this via the URLs /quietDown
and /cancelQuietDown
, or via the CLI commands [cancel-]quiet-down
.
Depening on what you want to achieve exactly you can probably use the Exclusive Execution Plugin. This plugin allows you to schedule a job which will block execution of all other jobs by putting Jenkins in shutdown mode (which is canceled when the job is done). You can make this job start at 6am and make ik run a simple ant script which sleeps for an hour.
However, if you are trying to use that window to e.g. run a backup you could actually run your backup from within that job, which will make 100% sure your backup won't start until all running jobs are completed and it will make Jenkins available again as soon as the backup is done.
Alternatively you could consider using cron or the windows scheduler (depending on your OS) to stop Jenkins completely at 6am and restart it at 7am.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With