forked from remote/site-ffmuc
Jenkinsfile: add mattermost notifications
This commit is contained in:
59
Jenkinsfile
vendored
59
Jenkinsfile
vendored
@@ -1,10 +1,51 @@
|
||||
node {
|
||||
stage 'Checkout'
|
||||
checkout scm
|
||||
|
||||
stage 'Build'
|
||||
sh "make V=s"
|
||||
|
||||
stage 'Archive'
|
||||
archive 'output/**/*'
|
||||
def _pipelineNotify(String buildStatus = 'STARTED') {
|
||||
// build status of null means successful
|
||||
buildStatus = buildStatus ?: 'SUCCESSFUL'
|
||||
|
||||
// Default values
|
||||
def colorName = 'RED'
|
||||
def colorCode = '#FF0000'
|
||||
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
|
||||
def summary = "${subject} (${env.BUILD_URL})"
|
||||
|
||||
// Override default values based on build status
|
||||
if (buildStatus == 'STARTED') {
|
||||
color = 'YELLOW'
|
||||
colorCode = '#FFFF00'
|
||||
} else if (buildStatus == 'SUCCESSFUL') {
|
||||
color = 'GREEN'
|
||||
colorCode = '#00FF00'
|
||||
} else {
|
||||
color = 'RED'
|
||||
colorCode = '#FF0000'
|
||||
}
|
||||
|
||||
try {
|
||||
mattermostSend (color: colorCode, message: summary)
|
||||
}
|
||||
catch (e) {
|
||||
echo 'Unable to sent Mattermost notification'
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
try {
|
||||
_pipelineNotify()
|
||||
|
||||
stage 'Checkout'
|
||||
checkout scm
|
||||
|
||||
stage 'Build'
|
||||
sh "make V=s"
|
||||
|
||||
stage 'Archive'
|
||||
archive 'output/**/*'
|
||||
}
|
||||
catch (e) {
|
||||
currentBuild.result = "FAILED"
|
||||
throw e
|
||||
}
|
||||
finally {
|
||||
_pipelineNotify(currentBuild.result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user