diff --git a/Jenkinsfile b/Jenkinsfile index f7f278b0edb89127f3dafbe58cd83ff9e3beb99d..4871966c2007edc974ffe9c55bc69331e02f0ab7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { } environment { - BLUE_OCEAN_URL = "https://jenkins.infra.ozg-cloud.systems/job/user-manager/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/" + JENKINS_URL = "https://jenkins.infra.ozg-cloud.systems/job/codeSH_user-manager/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/" RELEASE_REGEX = /\d+.\d+.\d+/ SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/ FAILED_STAGE = "" @@ -47,7 +47,7 @@ pipeline { when { not { anyOf { - branch 'master' + branch 'main' branch 'release' } } @@ -150,7 +150,7 @@ pipeline { stage('Sonar Checks') { when { - branch 'master' + branch 'main' } steps { script { @@ -179,7 +179,7 @@ pipeline { tagAndPushDockerImage(IMAGE_TAG) - if (env.BRANCH_NAME == 'master') { + if (isMainBranch()) { tagAndPushDockerImage('snapshot-latest') } else if (env.BRANCH_NAME == 'release') { @@ -209,7 +209,7 @@ pipeline { stage('Rollout Dev UserManager') { when { - branch 'master' + branch 'main' } steps { script { @@ -245,7 +245,7 @@ pipeline { stage('march build image') { when { - branch 'master' + branch 'main' } steps { script { @@ -270,7 +270,7 @@ pipeline { stage('march push image') { when { - branch 'master' + branch 'main' } steps { script { @@ -284,7 +284,7 @@ pipeline { post { failure { script { - if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'release') { + if (isMainBranch() || env.BRANCH_NAME == 'release') { sendFailureMessage() } } @@ -328,11 +328,11 @@ String buildVersionName() { Void sendFailureMessage() { def room = '' def data = """{"msgtype":"m.text", \ - "body":"UserManager: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \ + "body":"UserManager: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${JENKINS_URL}", \ "format": "org.matrix.custom.html", \ - "formatted_body":"UserManager: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}""" + "formatted_body":"UserManager: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${JENKINS_URL}'>${env.BUILD_NUMBER}</a>"}""" - if (env.BRANCH_NAME == 'master') { + if (isMainBranch()) { room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de" } else if (env.BRANCH_NAME == 'release') { @@ -428,4 +428,8 @@ Void tagAndPushDockerImage(String newTag) { sh "docker tag docker.ozg-sh.de/root/user-manager:build-latest docker.ozg-sh.de/user-manager:${newTag}" sh "docker push docker.ozg-sh.de/user-manager:${newTag}" } -} \ No newline at end of file +} + +Boolean isMainBranch() { + return env.BRANCH_NAME == 'main' +}