I'm running Jenkins in AWS and I'm writing a script that safely re-deploys the Jenkins CloudFormation stack. I'm not trying to simply restart the Jenkins web server. I know about the different "safe" options, but none of them seem to work for me:
http://<jenkins.server>/safeRestart- this seems to not work for me, since it just restarts the Jenkins web server. The jobs that were running before restart continue to run normally after restart. I'm trying to terminate the AWS instance.http://<jenkins.server>/safeExit- allows current jobs to finish, but immediately kills the Jenkins web server and there is no way for me to check when it's safe to terminate the AWS instance.http://<jenkins.server>/quietDown- this almost does exactly what I want. New jobs are queued, not started (good). The Jenkins web server is up and I can query for running jobs (good). However, running jobs go into this weird state, where upon job completion, the job doesn't actually exit. The console hangs withPausing (Preparing for shutdown). Because of this, I can't query for the number of the currently running jobs, since it picks up all the jobs in this weird state.
What are my options here? Is there something wrong with my setup? Is there a way to prevent jobs from entering Pausing (Preparing for shutdown) when Jenkins is in "quietDown" mode, and the job finishes?