没有从管道运行接收电子邮件通知

时间:2017-03-14 10:54:12

标签: jenkins jenkins-pipeline

我在接收我已设置的管道的电子邮件通知时遇到问题:

#!groovy
pipeline {
  agent any
  stages {
    stage('Build Prep') {
      steps {
        sh '...'
      }
    }
    stage('Build') {
      steps {
        sh '...'
      }
    }
    stage('Tests') {
      steps {
        parallel (
          "Jasmine": {
            sh '...'
          },
           "Mocha": {
            sh '...'
          }
        )
      }
    }
    stage('Deploy') {
      steps {
        sh "..."
      }
    }
  }
  post {
    success {
      emailext to:"me@me.com", subject:"SUCCESS: ${currentBuild.fullDisplayName}", body: "Yay, we passed."
    }
    failure {
      emailext to:"me@me.com", subject:"FAILURE: ${currentBuild.fullDisplayName}", body: "Boo, we failed."
    }
    unstable {
      emailext to:"me@me.com", subject:"UNSTABLE: ${currentBuild.fullDisplayName}", body: "Huh, we're unstable."
    }
    changed {
      emailext to:"me@me.com", subject:"CHANGED: ${currentBuild.fullDisplayName}", body: "Wow, our status changed!"
    }
  }
}

构建日志确认已发送电子邮件,但我的收件箱中没有任何内容,垃圾邮件也没有。

我遇到了这个https://jenkins.io/blog/2016/07/18/pipline-notifications/

但我不确定我是否可以使用我的语法,我没有定义任何节点,我应该吗?

1 个答案:

答案 0 :(得分:0)

你的脚本运行正常。我确实收到了使用上述代码的电子邮件。请检查您的其他设置,或者您是否为Jenkins电子邮件创建了规则。通过将通知添加到Jenkins共享库,可以使代码看起来更容易。请看下面的链接。

https://jenkins.io/doc/book/pipeline/shared-libraries/