在Jenkinsfile中是否有使用groovy发送最重要通知的指针?它类似于slacksend吗?
答案 0 :(得分:0)
这对我有用:
mattermostSend(color: colorCode, icon: "https://jenkins.io/images/logos/jenkins/jenkins.png", message: message, channel: *channelname*, endpoint: *yourwebhookendpoint*)
答案 1 :(得分:0)
从插件管理器安装 Mattermost 通知插件。
脚本:
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>)"
)
}
}
}
}
}
}
}