diff --git a/Jenkinsfile b/Jenkinsfile index a894875d656225534a88d6c9124c757cff83a8f6..212182f873a175d40f9ec8db39c9d9a7cf9b6210 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { } environment { - BLUE_OCEAN_URL = "https://jenkins.infra.ozg-cloud.systems/job/muk-postfach/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/" + JENKINS_URL = "https://jenkins.infra.ozg-cloud.systems/job/codeSH_muk-postfach/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' } } @@ -111,7 +111,7 @@ pipeline { stage('Sonar Checks') { when { - branch 'master' + branch 'main' } steps { script { @@ -137,7 +137,7 @@ pipeline { } failure { script { - if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'release') { + if (isMainBranch() || env.BRANCH_NAME == 'release') { sendFailureMessage() } } @@ -154,7 +154,7 @@ String getPomVersion(String pomFile){ String generateImageTag() { def imageTag = "${env.BRANCH_NAME}-${getPomVersion('pom.xml')}" - if (env.BRANCH_NAME == 'master') { + if (isMainBranch()) { imageTag += "-${env.GIT_COMMIT.take(7)}" } @@ -174,9 +174,9 @@ Void configureGit() { Void sendFailureMessage() { def room = '' def data = """{"msgtype":"m.text", \ - "body":"MUK-Postfach: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \ + "body":"MUK-Postfach: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${JENKINS_URL}", \ "format": "org.matrix.custom.html", \ - "formatted_body":"MUK-Postfach: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}""" + "formatted_body":"MUK-Postfach: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${JENKINS_URL}'>${env.BUILD_NUMBER}</a>"}""" if (env.BRANCH_NAME == 'main') { room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de" @@ -193,3 +193,7 @@ String getElementAccessToken() { return readJSON ( text: sh (script: '''curl -XPOST -d \"$LOGIN_JSON\" https://matrix.ozg-sh.de/_matrix/client/v3/login''', returnStdout: true)).access_token } } + +Boolean isMainBranch() { + return env.BRANCH_NAME == 'main' +}