[NC-1946] fix slack notifications for master build status (#335)

Chris Mckay 6 years ago committed by GitHub
parent 22498da50c
commit 25bc82f6ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 142
      Jenkinsfile

142
Jenkinsfile vendored

@ -18,89 +18,101 @@ if (env.BRANCH_NAME == "master") {
]) ])
} }
stage('Pantheon tests') { try {
parallel javaTests: { stage('Pantheon tests') {
node { parallel javaTests: {
checkout scm node {
docker.image('docker:18.06.0-ce-dind').withRun('--privileged') { d -> checkout scm
docker.image('pegasyseng/pantheon-build:0.0.1').inside("--link ${d.id}:docker") { docker.image('docker:18.06.0-ce-dind').withRun('--privileged') { d ->
try { docker.image('pegasyseng/pantheon-build:0.0.1').inside("--link ${d.id}:docker") {
stage('Compile') { try {
sh './gradlew --no-daemon --parallel clean compileJava' stage('Compile') {
} sh './gradlew --no-daemon --parallel clean compileJava'
stage('compile tests') { }
sh './gradlew --no-daemon --parallel compileTestJava' stage('compile tests') {
} sh './gradlew --no-daemon --parallel compileTestJava'
stage('assemble') { }
sh './gradlew --no-daemon --parallel assemble' stage('assemble') {
} sh './gradlew --no-daemon --parallel assemble'
stage('Build') { }
sh './gradlew --no-daemon --parallel build' stage('Build') {
} sh './gradlew --no-daemon --parallel build'
stage('Reference tests') { }
sh './gradlew --no-daemon --parallel referenceTest' stage('Reference tests') {
} sh './gradlew --no-daemon --parallel referenceTest'
stage('Integration Tests') { }
sh './gradlew --no-daemon --parallel integrationTest' stage('Integration Tests') {
} sh './gradlew --no-daemon --parallel integrationTest'
stage('Acceptance Tests') { }
sh './gradlew --no-daemon --parallel acceptanceTest' stage('Acceptance Tests') {
} sh './gradlew --no-daemon --parallel acceptanceTest'
stage('Check Licenses') { }
sh './gradlew --no-daemon --parallel checkLicenses' stage('Check Licenses') {
} sh './gradlew --no-daemon --parallel checkLicenses'
stage('Check javadoc') { }
sh './gradlew --no-daemon --parallel javadoc' stage('Check javadoc') {
} sh './gradlew --no-daemon --parallel javadoc'
stage('Jacoco root report') { }
sh './gradlew --no-daemon jacocoRootReport' stage('Jacoco root report') {
} sh './gradlew --no-daemon jacocoRootReport'
} finally { }
archiveArtifacts '**/build/reports/**' } finally {
archiveArtifacts '**/build/test-results/**' archiveArtifacts '**/build/reports/**'
archiveArtifacts 'build/reports/**' archiveArtifacts '**/build/test-results/**'
archiveArtifacts 'build/distributions/**' archiveArtifacts 'build/reports/**'
archiveArtifacts 'build/distributions/**'
junit '**/build/test-results/**/*.xml' junit '**/build/test-results/**/*.xml'
}
} }
} }
} }
} }, quickstartTests: {
}, quickstartTests: { node {
node { checkout scm
checkout scm docker.image('docker:18.06.0-ce-dind').withRun('--privileged') { d ->
docker.image('docker:18.06.0-ce-dind').withRun('--privileged') { d -> docker.image('pegasyseng/pantheon-build:0.0.1').inside("--link ${d.id}:docker") {
docker.image('pegasyseng/pantheon-build:0.0.1').inside("--link ${d.id}:docker") { try {
try { stage('Docker quickstart Tests') {
stage('Docker quickstart Tests') { sh 'DOCKER_HOST=tcp://docker:2375 ./gradlew --no-daemon --parallel clean dockerQuickstartTest'
sh 'DOCKER_HOST=tcp://docker:2375 ./gradlew --no-daemon --parallel clean dockerQuickstartTest' }
} } finally {
} finally { archiveArtifacts '**/build/test-results/**'
archiveArtifacts '**/build/test-results/**' archiveArtifacts '**/build/reports/**'
archiveArtifacts '**/build/reports/**'
junit '**/build/test-results/**/*.xml' junit '**/build/test-results/**/*.xml'
}
} }
} }
} }
} }
} }
} } catch (e) {
currentBuild.result = 'FAILURE'
// If we're on master and it failed, notify slack } finally {
if (env.BRANCH_NAME == "master") { // If we're on master and it failed, notify slack
if (currentBuild.result != 'SUCCESSFUL') { if (env.BRANCH_NAME == "master") {
def currentResult = currentBuild.result ?: 'SUCCESS'
def channel = '#priv-pegasys-prod-dev' def channel = '#priv-pegasys-prod-dev'
if (currentBuild.result == 'FAILURE') { if (currentResult == 'SUCCESS') {
def previousResult = currentBuild.previousBuild?.result
if (previousResult != null && (previousResult == 'FAILURE' || previousResult == 'UNSTABLE')) {
slackSend(
color: 'good',
message: "Pantheon branch ${env.BRANCH_NAME} build is back to HEALTHY.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}",
channel: channel
)
}
} else if (currentBuild.result == 'FAILURE') {
slackSend( slackSend(
color: 'danger', color: 'danger',
msg: "Pantheon master branch build is FAILING.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}", message: "Pantheon branch ${env.BRANCH_NAME} build is FAILING.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}",
channel: channel channel: channel
) )
} else if (currentBuild.result == 'UNSTABLE') { } else if (currentBuild.result == 'UNSTABLE') {
slackSend( slackSend(
color: 'warning', color: 'warning',
msg: "Pantheon master branch build is UNSTABLE.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}", message: "Pantheon branch ${env.BRANCH_NAME} build is UNSTABLE.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}",
channel: channel channel: channel
) )
} }

Loading…
Cancel
Save