Creating a job that always sends an email on job completion in Jenkins
def emailTrigger = {
email {
subject "\$PROJECT_DEFAULT_SUBJECT"
body "\$PROJECT_DEFAULT_CONTENT"
recipientProviders {
'hudson.plugins.emailext.plugins.recipients.ListRecipientProvider'{}
}
attachBuildLog false
compressBuildLog false
replyTo "\$PROJECT_DEFAULT_REPLYTO"
contentType "project"
}
}
job = freeStyleJob('emailtest') {
steps {
shell('ls')
}
configure { project ->
project / publishers << 'hudson.plugins.emailext.ExtendedEmailPublisher'(plugin: 'email-ext@2.68') {
recipientList 'recipientEmail@somewhere.com'
configuredTriggers {
'hudson.plugins.emailext.plugins.trigger.AlwaysTrigger' emailTrigger
}
contentType 'text/html'
defaultSubject "Email Subject"
defaultContent "<p>Email Content</p>"
attachmentsPattern{}
presendScript '\$DEFAULT_PRESEND_SCRIPT'
postsendScript '\$DEFAULT_POSTSEND_SCRIPT'
attachBuildLog false
compressBuildLog false
replyTo 'youremail@replyto.com'
from 'youremail@from.com'
saveOutput false
disabled false
}
}
}