如何使用groovy在Jenkins中发送最重要的通知?
在Jenkins文件中有关于使用groovy发送mattermost通知的指针吗?它与slacksend类似吗?这对我很有用:如何使用groovy在Jenkins中发送最重要的通知?,jenkins,mattermost,Jenkins,Mattermost,在Jenkins文件中有关于使用groovy发送mattermost通知的指针吗?它与slacksend类似吗?这对我很有用: mattermostSend(color: colorCode, icon: "https://jenkins.io/images/logos/jenkins/jenkins.png", message: message, channel: *channelname*, endpoint: *yourwebhookendpoint*) 从插件管理器安装Mattermo
mattermostSend(color: colorCode, icon: "https://jenkins.io/images/logos/jenkins/jenkins.png", message: message, channel: *channelname*, endpoint: *yourwebhookendpoint*)
从插件管理器安装Mattermost通知插件
脚本:
你需要最新的插件来运行命令mattermostsend吗?@Bruce227是的,你需要。
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>)"
)
}
}
}
}
}
}
}