Reputation: 51
I would like to configure email notifications using Job DSL instead of email-ext plugin.
Upvotes: 3
Views: 6033
Reputation: 1859
I'm using the Pipeline/Workflow DSL and got this working:
mail from: "",
to: "[email protected]",
subject: """Jenkins ${env.JOB_NAME} [${env.BUILD_NUMBER}]""",
mimeType: "text/html",
body: """Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>
<pre>${summary}</pre>"""
Upvotes: 0
Reputation: 7982
The DSL does not provide the capability of other plugins, it merely exposes their capability to the script. The plugins still need to be installed.
As per the DSL API Docs, DSL has support for the Jenkins mailer plugin (included as standard),
job('example') {
publishers {
mailer('[email protected]', true, true)
}
}
This is not particularly customizable - you can't tell it to email after every passing build.
The email extension plugin is also supported by DSL:
job('example') {
publishers {
extendedEmail {
recipientList('[email protected]')
defaultSubject('Oops')
defaultContent('Something broken')
contentType('text/html')
triggers {
beforeBuild()
stillUnstable {
subject('Subject')
content('Body')
sendTo {
developers()
requester()
culprits()
}
}
}
}
}
}
To email after every build regardless of status, using email-ext, you can use the always trigger (in place of stillUnstable trigger in the above example)
(code samples copied from linked documentation for the sake of surviving downtime.)
Upvotes: 9