From 55568227057966b1c43eac16d8fac5de3363278a Mon Sep 17 00:00:00 2001 From: Jack-Leung <38930117+Jack-Leung@users.noreply.github.com> Date: Sun, 15 Mar 2020 22:04:39 -0400 Subject: [PATCH] fixing bugs --- Jenkinsfile | 86 +++++++++++++++-------------------------------------- 1 file changed, 24 insertions(+), 62 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 78469c85c..02616759c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,67 +1,29 @@ pipeline { agent any - node { - try { - notifySlack('STARTED') - - stages { - stage('Build') { - steps { - sh './mvnw package' - } - } - - stage('Testing') { - steps { - echo 'Testing' - } - } - - stage('Package') { - steps { - echo 'Packaging' - } - } - - stage('Deploy') { - steps { - echo 'Deploying' - } - } + stages { + stage('Build') { + steps { + sh './mvnw package' } - } catch (e) { - // If there was an exception thrown, the build failed - currentBuild.result = "FAILED" - throw e - } finally { - // Success or failure, always send notifications - notifySlack(currentBuild.result) } - } -} - -def notifySlack(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) + + stage('Testing') { + steps { + echo 'Testing' + } + } + + stage('Package') { + steps { + echo 'Packaging' + } + } + + stage('Deploy') { + steps { + echo 'Deploying' + } + } + } + slackSend "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})" }