mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 23:05:50 +00:00
adding slack notif
This commit is contained in:
parent
32bee7d881
commit
2e49a9bfb6
1 changed files with 31 additions and 40 deletions
69
Jenkinsfile
vendored
69
Jenkinsfile
vendored
|
@ -1,48 +1,39 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
stages {
|
stages {
|
||||||
script {
|
stage('Build') {
|
||||||
try {
|
steps {
|
||||||
notifySlack('STARTED')
|
bat 'mvn clean'
|
||||||
|
|
||||||
stage('Build') {
|
|
||||||
echo 'build'
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e) {
|
stage('Testing') {
|
||||||
// If there was an exception thrown, the build failed
|
steps {
|
||||||
currentBuild.result = "FAILED"
|
bat 'mvn test'
|
||||||
throw e
|
}
|
||||||
} finally {
|
}
|
||||||
// Success or failure, always send notifications
|
|
||||||
notifySlack(currentBuild.result)
|
stage('Package') {
|
||||||
|
steps {
|
||||||
|
bat 'mvn package'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy') {
|
||||||
|
when{
|
||||||
|
branch 'master'
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
bat 'mvn deploy'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
post{
|
||||||
|
success{
|
||||||
def notifySlack(String buildStatus = 'STARTED') {
|
slackSend color: "good", message: "Success: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
|
||||||
// build status of null means successful
|
}
|
||||||
buildStatus = buildStatus ?: 'SUCCESSFUL'
|
failure{
|
||||||
|
slackSend color: "danger", message: "Failure: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
|
||||||
// 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