简体   繁体   English

声纳质量门和电子邮件 Jenkins 管道

[英]Sonar Qality gates and email Jenkins Pipeline

As I want to configure that if my Quality Gate of Sonar Qube gives status error, it should not allow any thing in the body but Send email from Email Ext in Jenkins Pipeline.因为我想配置,如果我的 Sonar Qube 的 Quality Gate 给出状态错误,它不应该允许正文中的任何内容,而是从 Jenkins Pipeline 中的 Email Ext 发送电子邮件。

 stage("Quality Gate"){
          steps{

              script{
         timeout(time: 1, unit: 'HOURS') {
             def qg = waitForQualityGate()
             if (qg.status != 'OK') {
                 error "Pipeline aborted due to quality gate failure: ${qg.status}"

         }
      }
  post {
        always {
  emailext attachmentsPattern:'Cucumber HTML Reports/$BUILD_NUMBER/cucumber-html-reports.zip' ,body:"$EMAILTEMPLATE$URLS $SONARQUBE ", mimeType: 'text/html', recipientProviders: [developers()], subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!', to: ' xyz@abc.com'
            }
}

You need to configure webhook on Sonar side to your Jenkins master, otherway it will always wait and failing on timeout.您需要将声纳端的 webhook 配置到您的 Jenkins 主服务器,否则它将始终等待并在超时时失败。 Email will be send cause you configured it in post stage, parametrized and with 'always' condition电子邮件将被发送,因为您在后期阶段对其进行了配置、参数化并具有“始终”条件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM