Reputation: 91
I want jenkin to send an email for example 3 hours earlier, before a job runs. Email Notification or Editable Email Notification give no option of scheduling the Email Notifications. The purpose of such kind of notification is that the other departments in our company knows in advance that some specific job is gonna run and they do necessary steps before a job can run. Any idea or clue will be appreciated.
Upvotes: 0
Views: 1452
Reputation: 1552
Add a pre-build step and add "Execute shell" option. Add unix script for sending email with appropriate content. Add sleep command for 3 hours to hold the build for next 3 hours.
mailx -S smtp=$smtphost:$smtpport -s "subject line" -v [email protected] sleep 3600
Upvotes: 1
Reputation: 1089
You may add a 'pre-build' stage to your pipeline, which send a notification email about upcoming job run. You can also set a 'sleep' operation afterwards to give your colleagues some time to prepare:
pipeline {
stages {
stage('Pre-Build Email'){
emailext(
body: 'Job XYZ is about to run in 30 minutes.',
from: env.DEFAULT_REPLYTO,
replyTo: env.DEFAULT_REPLYTO,
subject: 'Job XYZ notification',
to: [email protected]'
)
sleep(time:30,unit:"MINUTES")
}
// Rest of the build here
Upvotes: 0