From 99192e2141fd1b2d818bd12c577257217f448dc1 Mon Sep 17 00:00:00 2001
From: Martin <git@mail.de>
Date: Thu, 19 Dec 2024 19:45:01 +0100
Subject: [PATCH] OZG-7324 adjust JenkinsFile

---
 Jenkinsfile | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 0ad5fc4..eae047f 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -6,7 +6,7 @@ pipeline {
     }
 
     environment {
-        BLUE_OCEAN_URL = "https://jenkins.infra.ozg-cloud.systems/job/ozgcloud-collaboration-manager/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
+        JENKINS_URL = "https://jenkins.infra.ozg-cloud.systems/job/codeSH_collaboration-manager/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
         RELEASE_REGEX = /\d+.\d+.\d+/
         SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/
         FAILED_STAGE = ""
@@ -42,7 +42,7 @@ pipeline {
           when {
             not {
                 anyOf {
-                    branch 'master'
+                    branch 'main'
                     branch 'release'
                 }
             }
@@ -82,7 +82,7 @@ pipeline {
 
         stage('Sonar Checks') {
             when {
-                branch 'master'
+                branch 'main'
             }
         	steps {
         	     script {
@@ -108,7 +108,7 @@ pipeline {
         }
         failure {
             script {
-                if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'release') {
+                if (isMainBranch() || env.BRANCH_NAME == 'release') {
                     sendFailureMessage()
                 }
             }
@@ -119,11 +119,11 @@ pipeline {
 Void sendFailureMessage() {
     def room = ''
     def data = """{"msgtype":"m.text",
-                    "body":"Collaboration-Manager: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}",
+                    "body":"Collaboration-Manager: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${JENKINS_URL}",
                     "format": "org.matrix.custom.html",
-                    "formatted_body":"<h3>Collaboration-Manager: Build Failed.</h3><b>Stage:</b> ${FAILED_STAGE}<br><b>Build-ID:</b> <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}"""
+                    "formatted_body":"<h3>Collaboration-Manager: Build Failed.</h3><b>Stage:</b> ${FAILED_STAGE}<br><b>Build-ID:</b> <a href='${JENKINS_URL}'>${env.BUILD_NUMBER}</a>"}"""
 
-    if (env.BRANCH_NAME == 'master') {
+    if (isMainBranch()) {
         room = "!GjqhmouBtnDbwUkAjx:matrix.ozg-sh.de"
     }
     else if (env.BRANCH_NAME == 'release') {
@@ -143,4 +143,8 @@ String getPomVersion(String pomFile){
     def pom = readMavenPom file: pomFile
 
     return pom.version
-}
\ No newline at end of file
+}
+
+Boolean isMainBranch() {
+    return env.BRANCH_NAME == 'main'
+}
-- 
GitLab