I would like to send an e-mail notification to all users listed in the People tab in the job view:
The post Use Jenkins 'Mailer' inside pipeline workflow shows how to send e-mail notifications within a Jenkinsfile:
emailext(body: '${DEFAULT_CONTENT}', mimeType: 'text/html',
replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}',
to: emailextrecipients([[$class: 'CulpritsRecipientProvider'],
[$class: 'RequesterRecipientProvider']]))
I modified it to send e-mails only if the build failed or fixed, inspired by Justin Simons comment in https://baptiste-wicht.com/posts/2017/06/jenkins-tip-send-notifications-fixed-builds-declarative-pipeline.html#comment-3478592834:
mailNotificationAlreadySend = false
pipeline {
...
stages {
...
}
post {
changed {
sendMailNotification()
}
failure {
sendMailNotification()
}
}
}
void sendMailNotification() {
if (!mailNotificationAlreadySend) {
emailext(body: '${DEFAULT_CONTENT}', mimeType: 'text/html',
replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}',
recipientProviders: [[$class: 'DevelopersRecipientProvider'],
[$class: 'CulpritsRecipientProvider']]
)
mailNotificationAlreadySend = true
}
}
But this sends the e-mails only to the developer who caused the build fail and all following contributors until the build result is successful again.
How should the emailext method be configured to send e-mails to all users listed in the People tab in the job view?
I already tried all recipientProviders available in https://github.com/jenkinsci/email-ext-plugin/tree/master/src/main/java/hudson/plugins/emailext/plugins/recipients without any success.