0

I want to send email notifications through a Jeenkins Scripted Pipeline, when any job gets done. Email to a specific developer/group who checked into git. I need help with said script.

1 Answers1

0

Use Email-ext plugin, configure it with docs and add similar code:

pipeline {
    agent any

    stages {
        stage('Build') {
            steps {
                sh "sh deploy.sh"
            }
        }
    }
    post {
        always {
            emailext body: 'Hello sainath kadaverugu', recipientProviders: [$class: 'DevelopersRecipientProvider'], subject: 'After build message'
        }
    }
}

If You want to get last committer email address checkout this thread

EDIT: in "node-style" I used mailer

def get_mail() {
    node('master'){
        USER_MAIL = wrap([$class: 'BuildUser']) {
            return env.BUILD_USER_EMAIL
        }
    }
}

def USER_MAIL = get_mail()

node('master') {
   stage('Checkout') {
       deleteDir()
       git 'git@sometest.git'
    }

    stage('Deploy') {
        sh "sh depoly.sh"
    }
    step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: USER_MAIL, sendToIndividuals: true])
}
3sky
  • 830
  • 1
  • 7
  • 16
  • Thanks for your reply, we have requirement of pipeline node script, please help me with node script(same script in node).with success or failure status – sainath kadaverugu Oct 17 '18 at 04:04