jenkins notifying error occured in different steps by sending mail in Pipeline (former known as Workflow)

后端 未结 3 1169
长情又很酷
长情又很酷 2020-12-06 13:20

I have a pipeline with multiple steps, for example:

stage \'dev - compile\'
node(\'master\') {
  //do something
}

stage \'test- compile\'
node(\'master\') {         


        
3条回答
  •  青春惊慌失措
    2020-12-06 13:59

    I think it is a better way to use the jenkins build in post section instead of using try catch:

    pipeline {
      agent any
        stages {
          stage('whatever') {
            steps {
              ...
            }
          }
        }
        post {
            always {
              step([$class: 'Mailer',
                notifyEveryUnstableBuild: true,
                recipients: "example@example.com",
                sendToIndividuals: true])
            }
          }
        }
      }
    }
    

提交回复
热议问题