Email Notification using Code as Configuration

24 views Asked by At

I’m new to using Jenkins and I would like to set up email notifications when a job fails using Job DSL and Configuration as Code. I’ve tried the code snippets below, but none of them are working I might be missing a part of the process.

I would be grateful if someone could help me out. Thank you! :)

job.groovy

            publishers {
                extendedEmail {
                    recipientList('[email protected]')
                    defaultSubject('Oops')
                    defaultContent('Something broken')
                    contentType('text/html')
                    attachBuildLog(true)
                    triggers {
                        failure {
                            subject('Build Failed')
                            content('The build has failed.')
                            sendTo {
                                developers()
                                requester()
                                culprits()
                            }
                        }
                    }
                }
            }

config.yml

      location:
        adminAddress: "[email protected]"
      mailer:
        smtpHost: "smtp.gmail.com"
        smtpPort: "587"
        useSsl: false
        charset: "UTF-8"
        replyToAddress: "[email protected]"
0

There are 0 answers