From 612b2d1850b870a2d7c707ad6348ac6317402faa Mon Sep 17 00:00:00 2001
From: Martin <git@mail.de>
Date: Thu, 19 Dec 2024 11:42:13 +0100
Subject: [PATCH] OZG-7324 adjust JenkinsFile

---
 Jenkinsfile | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 9a0e68a..7829463 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -8,7 +8,7 @@ pipeline {
     }
 
     environment {
-        BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/job/api-lib/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
+        JENKINS_URL = "https://jenkins.ozg-sh.de/job/codeSH_api-lib/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/"
         RELEASE_REGEX = /\d+.\d+.\d+/
         SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/
     }
@@ -43,7 +43,7 @@ pipeline {
           when {
             not {
                 anyOf {
-                    branch 'master'
+                    branch 'main'
                     branch 'release'
                 }
             }
@@ -85,7 +85,7 @@ pipeline {
    post {
       failure {
           script {
-              if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'release') {
+              if (isMainBranch() || env.BRANCH_NAME == 'release') {
                   sendFailureMessage()
               }
           }
@@ -96,11 +96,11 @@ pipeline {
 Void sendFailureMessage() {
     def room = ''
     def data = """{"msgtype":"m.text", \
-                    "body":"api-lib: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \
+                    "body":"api-lib: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${JENKINS_URL}", \
                     "format": "org.matrix.custom.html", \
-                    "formatted_body":"api-lib: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}"""
+                    "formatted_body":"api-lib: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <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') {
@@ -120,4 +120,8 @@ String getPomVersion(String pomFile){
     def pom = readMavenPom file: pomFile
 
     return pom.version
+}
+
+Boolean isMainBranch() {
+    return env.BRANCH_NAME == 'main'
 }
\ No newline at end of file
-- 
GitLab