From 859f121024b0b9cd40ec7b8cdfde60b25466514b Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Wed, 21 Apr 2021 11:24:51 +0200
Subject: [PATCH] OZG-533 add slack notification

---
 Jenkinsfile | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 38814362a8..c3e99d842e 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -7,6 +7,10 @@ pipeline {
         }
     }
 
+    environment {
+        BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/blue/organizations/jenkins/goofy/detail/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/pipeline"
+    }
+
     options {
         timeout(time: 1, unit: 'HOURS')
         disableConcurrentBuilds()
@@ -34,16 +38,16 @@ pipeline {
                                 sh 'npm run ci-build'
                             }
 
-//                            sh 'npm run ci-test'
+                            // sh 'npm run ci-test'
                         }
                     }
                 }
             }
-       //     post {
-       //         always{
-       //             junit testResults: 'goofy-client/test-report.xml', skipPublishingChecks: true
-       //         }
-       //     } 
+            // post {
+            //     always{
+            //         junit testResults: 'goofy-client/test-report.xml', skipPublishingChecks: true
+            //     }
+            // }
         }
 
         stage('Server') {
@@ -155,6 +159,9 @@ pipeline {
             }
             
             steps {
+                script {
+                    FAILED_STAGE = env.STAGE_NAME
+                }
                 container("docker") {
                     script {
                         withCredentials([usernamePassword(credentialsId: 'jenkins-docker-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
@@ -189,4 +196,13 @@ pipeline {
             }
         }
     }
+    post {
+        failure {
+            script {
+                if (env.BRANCH_NAME == 'master') {
+                    slackSend(color: "danger", message: "Goofy: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <${BLUE_OCEAN_URL}|${env.BUILD_NUMBER}>")
+                }
+            }
+        }
+    }
 }
\ No newline at end of file
-- 
GitLab