- You would like to receive a notification every time your instance is restarted.
- CloudBees CI (CloudBees Core)
- CloudBees CI (CloudBees Core) on modern cloud platforms - Managed Master
- CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center
- CloudBees CI (CloudBees Core) on traditional platforms - Client Master
- CloudBees CI (CloudBees Core) on traditional platforms - Operations Center
- CloudBees Jenkins Enterprise
- CloudBees Jenkins Enterprise - Managed Master
- CloudBees Jenkins Enterprise - Operations Center
- CloudBees Jenkins Platform - Client Master
- CloudBees Jenkins Platform - Operations Center
- CloudBees Jenkins Distribution
- Jenkins LTS
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:
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.