mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 14:55:51 +00:00
adding slack send
This commit is contained in:
parent
eafc553e35
commit
db85f23189
1 changed files with 50 additions and 9 deletions
51
Jenkinsfile
vendored
51
Jenkinsfile
vendored
|
@ -1,15 +1,56 @@
|
|||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
try {
|
||||
notifyBuild('STARTED')
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh './mvnw package'
|
||||
}
|
||||
|
||||
stage('Testing') {
|
||||
echo 'Testing'
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
echo 'Testing..'
|
||||
|
||||
stage('Package') {
|
||||
echo 'Staging'
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
echo 'Deploy'
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
// If there was an exception thrown, the build failed
|
||||
currentBuild.result = "FAILED"
|
||||
throw e
|
||||
} finally {
|
||||
// Success or failure, always send notifications
|
||||
notifyBuild(currentBuild.result)
|
||||
}
|
||||
}
|
||||
|
||||
def notifyBuild(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'
|
||||
}
|
||||
|
||||
// Send notifications
|
||||
slackSend (color: colorCode, message: summary)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue