diff --git a/Jenkinsfile b/Jenkinsfile index 1ae2ae1271c289c6559e15248c6e2d12fc25ba4b..e7d513aa4befdf424516a878a3ae1e1f1a16d740 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { } environment { - BLUE_OCEAN_URL = "https://jenkins.infra.ozg-cloud.systems/job/antragraum-server/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/" + JENKINS_URL = "https://jenkins.infra.ozg-cloud.systems/job/codeSH_antragsraum-server/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' } } @@ -72,7 +72,7 @@ pipeline { configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) { sh 'mvn --no-transfer-progress -s $MAVEN_SETTINGS clean install -Dmaven.wagon.http.retryHandler.count=3' - if (env.BRANCH_NAME == 'master') { + if (isMainBranch()) { try { withSonarQubeEnv('sonarqube-ozg-sh'){ sh 'mvn -s $MAVEN_SETTINGS sonar:sonar' @@ -120,7 +120,7 @@ pipeline { tagAndPushDockerImage(IMAGE_TAG) - if (env.BRANCH_NAME == 'master') { + if (isMainBranch()) { tagAndPushDockerImage('snapshot-latest') } @@ -152,7 +152,7 @@ pipeline { stage('Trigger Dev rollout') { when { - branch 'master' + branch 'main' } steps { script { @@ -209,7 +209,7 @@ pipeline { } failure { script { - if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'release') { + if (isMainBranch() || env.BRANCH_NAME == 'release') { sendFailureMessage() } } @@ -337,11 +337,11 @@ Boolean hasValuesFileChanged(String environment) { Void sendFailureMessage() { def room = '' def data = """{"msgtype":"m.text", \ - "body":"AntragraumServer: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \ + "body":"AntragraumServer: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${JENKINS_URL}", \ "format": "org.matrix.custom.html", \ - "formatted_body":"AntragraumServer: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}""" + "formatted_body":"AntragraumServer: 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') { @@ -356,3 +356,8 @@ 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' +}