Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing Jenkins from executing new builds in a defined time frame (e.g. 6-7am)

Tags:

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)?

like image 877
datka Avatar asked Dec 12 '11 10:12

datka


People also ask

How can I prevent Jenkins from starting new jobs after a restart?

In order to prevent Jenkins from executing any jobs, you need to put it in "quiet down" mode when it starts up.

How can you prevent two Jenkins from running in parallel?

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."


2 Answers

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.

like image 122
Christopher Orr Avatar answered Dec 28 '22 22:12

Christopher Orr


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.

like image 42
AVee Avatar answered Dec 28 '22 23:12

AVee