#47 Send email in case of failed run
Merged 4 years ago by mikeb. Opened 4 years ago by mkovarik.
mkovarik/c3i-library send_email  into  master

@@ -261,10 +261,6 @@ 

                def recipient = params.MAIL_ADDRESS

                def subject = "Jenkins job ${env.JOB_NAME} #${env.BUILD_NUMBER} failed."

                def body = "Build URL: ${env.BUILD_URL}"

-               if (env.PR_NO) {

-                 subject = "Jenkins job ${env.JOB_NAME}, PR #${env.PR_NO} ${status}."

-                 body += "\nPull Request: ${env.PR_URL}"

-               }

                emailext to: recipient, subject: subject, body: body

              } catch (e) {

                echo "Error sending email: ${e}"

@@ -76,4 +76,21 @@ 

        }

      }

    }

+   post {

+     failure {

+       script {

+         // sending email

+         if (params.MAIL_ADDRESS){

+           try {

+             def recipient = params.MAIL_ADDRESS

+             def subject = "Jenkins job ${env.JOB_NAME} #${env.BUILD_NUMBER} failed."

+             def body = "Build URL: ${env.BUILD_URL}"

+             emailext to: recipient, subject: subject, body: body

+           } catch (e) {

+             echo "Error sending email: ${e}"

+           }

+         }

+       }

+     }

+   }

  }

@@ -42,4 +42,21 @@ 

      }

      {{ task_var_integration_test }}

    }

+   post {

+     failure {

+       script {

+         // sending email

+         if (params.MAIL_ADDRESS){

+           try {

+             def recipient = params.MAIL_ADDRESS

+             def subject = "Jenkins job ${env.JOB_NAME} #${env.BUILD_NUMBER} failed."

+             def body = "Build URL: ${env.BUILD_URL}"

+             emailext to: recipient, subject: subject, body: body

+           } catch (e) {

+             echo "Error sending email: ${e}"

+           }

+         }

+       }

+     }

+   }

  }

Send email notification about failed result for postmerge, trigger on
tag and greenwave promotion.

Pull-Request has been merged by mikeb

4 years ago