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 {
|
def _pipelineNotify(String buildStatus = 'STARTED') {
|
||||||
stage 'Checkout'
|
// build status of null means successful
|
||||||
checkout scm
|
buildStatus = buildStatus ?: 'SUCCESSFUL'
|
||||||
|
|
||||||
stage 'Build'
|
// Default values
|
||||||
sh "make V=s"
|
def colorName = 'RED'
|
||||||
|
def colorCode = '#FF0000'
|
||||||
stage 'Archive'
|
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
|
||||||
archive 'output/**/*'
|
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