Any pointers on sending mattermost notifications using groovy in the Jenkinsfile? Is it similar to slacksend?
Asked
Active
Viewed 3,632 times
2 Answers
1
This worked for me:
mattermostSend(color: colorCode, icon: "https://jenkins.io/images/logos/jenkins/jenkins.png", message: message, channel: *channelname*, endpoint: *yourwebhookendpoint*)

cmathews
- 116
- 2
- 13
-
Do you need the matter most plugin to run that command(mattermostSend)? – Bruce227 Oct 08 '19 at 17:37
-
@Bruce227 Yes, you need. – Wie May 05 '20 at 16:16
1
Install the Mattermost Notification Plugin from Plugin Manager.
Scripts:
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>)"
)
}
}
}
}
}
}
}

Shashwot Risal
- 121
- 1
- 4