Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow running some jobs when Jenkins/Hudson is in shutdown mode

Normally, selecting "Prepare for Shutdown" under "Manage Jenkins" prevents new jobs from being started (and I guess it's identical behavior under Hudson).

Now I'd like to run some maintenance jobs while Jenkins is in this shutdown mode. I didn't find any "Allow running even when Jenkins is shutting down" (or even better, "Allow running only while shutting down."

I'm actually thinking of creating a special build step, which will put Jenkins in shutdown mode, then wait and block the build until it detects that Jenkins has gone to shutdown mode and all other jobs have finished, and then continue that build. Natural pair for this is another custom build step, which will either trigger a Jenkins restart or disable shutdown mode, to be run after maintenance step is over.

But before I start coding, is there an existing solution, a plugin or whatever?

If there's a Groovy guru reading this, I would not mind the few lines of Groovy script to do this as an answer. It'd be a good excuse to get Groovy plugin installed ;-)

like image 915
hyde Avatar asked Dec 07 '25 03:12

hyde


1 Answers

Take a look at the Exclusive Execution Plugin. It's NOT designed to execute during any arbitrary shutdown-mode, but it IS designed so that when run, it enters shutdown-mode (to prevent other jobs from running), then runs itself, then exits shutdown mode.

like image 100
Jason Swager Avatar answered Dec 08 '25 21:12

Jason Swager



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!