0

关于在 Jenkinsfile 中使用 groovy 发送最重要通知的任何指示?它类似于 slacksend 吗?

4

2 回答 2

1

这对我有用:

mattermostSend(color: colorCode, icon: "https://jenkins.io/images/logos/jenkins/jenkins.png", message: message, channel: *channelname*, endpoint: *yourwebhookendpoint*)
于 2018-12-12T17:07:21.357 回答
1
  1. 从插件管理器安装 Mattermost 通知插件。

  2. 脚本:

pipeline {
    agent any

    stages {
        stage('Build') {
      steps {
        script {
        try {
            mattermostSend (
            color: "#2A42EE",
            channel: 'Build_BOT',
            endpoint: 'https://linktomattermost.com/hooks/yuwrgjeh38246239jkfh', 
            message: "Build STARTED: ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|Link to build>)"
            )               
        sh '''
            mvn -B -DskipTests clean package
           '''
            } catch(e) {
                   currentBuild.result = "FAILURE"
            } finally {
                 if(currentBuild.result == "FAILURE") {
                    mattermostSend (
                       color: "#e00707",
                        channel: 'Build_BOT', 
                        endpoint: 'https://linktomattermost.com/hooks/yuwrgjeh38246239jkfh',
                         message: "Build FAILED: ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|Link to build>)"
                     )
                 } else {
                       mattermostSend (
                           color: "#00f514",
                            channel: 'Build_BOT', 
                            endpoint: 'https://linktomattermost.com/hooks/yuwrgjeh38246239jkfh',
                           message: "Build SUCCESS: ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|Link to build>)"
                            )
                        }                            
                    }
            }
        }
    }
    }
}
于 2021-02-26T16:16:57.920 回答