How to send Slack notification after Jenkins pipeline build failed?

后端 未结 3 503
情书的邮戳
情书的邮戳 2020-12-23 16:48

I have a pipeline groovy script in Jenkins v2.19. Also I have a
\"Slack Notification Plugin\" v2.0.1 and \"Groovy Postbuild Plugin\".

I have successfully send a

3条回答
  •  情书的邮戳
    2020-12-23 17:19

    Just in case if in Declarative Syntax,

    Now, Jenkins provides post. You can check result at the end of pipeline.

    https://jenkins.io/doc/book/pipeline/syntax/#post-example

    Using like:

    pipeline {
        stages { ... }
        post {
           // only triggered when blue or green sign
           success {
               slackSend ...
           }
           // triggered when red sign
           failure {
               slackSend ...
           }
           // trigger every-works
           always {
               slackSend ...
           }
        }
    }
    

    It would be used in every stage also. See the document link please.

提交回复
热议问题