Environment
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center
-
CloudBees CI (CloudBees Core) on traditional platforms - Client controller
-
CloudBees CI (CloudBees Core) on traditional platforms - Operations Center
-
CloudBees Jenkins Enterprise
-
CloudBees Jenkins Enterprise - Managed controller
-
CloudBees Jenkins Enterprise - Operations center
Resolution
To achieve this, you may add an initialization script which on every startup will queue up a job that will then send a notification that the CloudBees CI instance has started back up.
To do so, you will need to create a new pipeline in your instance, ex: RestartNotificationJob
, and add the necessary code which will send the needed notification. For example the script which will setup an email notification from this job:
emailext body: 'RestartNotificationBody', subject: 'RestartNotificationSubject', to: 'DestinationEmail'
Once the job is setup, you will need to create a new script on the server in the $JENKINS_HOME/init.groovy.d/
folder (If the init.groovy.d
folder does not exist you will simply need to create this directory first), which will be responsible for adding the job to the queue. This script needs to be appended with .groovy
to run, ex: 999-queuejob.groovy
.
The below code may then be added to the script to trigger the previously configured job:
def job = hudson.model.Hudson.instance.getJob("RestartNotificationJob") hudson.model.Hudson.instance.queue.schedule(job, 0)
This allows the selected RestartNotificationSubject
job which will then send the email notification once the instance is fully up and running signalling a successful restart.