Skip to content
Snippets Groups Projects
Commit c9b0ec3e authored by Martin's avatar Martin
Browse files

OZG-7324 adjust JenkinsFile

parent a40446ba
Branches
Tags
No related merge requests found
...@@ -6,7 +6,7 @@ pipeline { ...@@ -6,7 +6,7 @@ pipeline {
} }
environment { 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+/ RELEASE_REGEX = /\d+.\d+.\d+/
SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/ SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/
FAILED_STAGE = "" FAILED_STAGE = ""
...@@ -42,7 +42,7 @@ pipeline { ...@@ -42,7 +42,7 @@ pipeline {
when { when {
not { not {
anyOf { anyOf {
branch 'master' branch 'main'
branch 'release' branch 'release'
} }
} }
...@@ -111,7 +111,7 @@ pipeline { ...@@ -111,7 +111,7 @@ pipeline {
stage('Sonar Checks') { stage('Sonar Checks') {
when { when {
branch 'master' branch 'main'
} }
steps { steps {
script { script {
...@@ -137,7 +137,7 @@ pipeline { ...@@ -137,7 +137,7 @@ pipeline {
} }
failure { failure {
script { script {
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'release') { if (isMainBranch() || env.BRANCH_NAME == 'release') {
sendFailureMessage() sendFailureMessage()
} }
} }
...@@ -154,7 +154,7 @@ String getPomVersion(String pomFile){ ...@@ -154,7 +154,7 @@ String getPomVersion(String pomFile){
String generateImageTag() { String generateImageTag() {
def imageTag = "${env.BRANCH_NAME}-${getPomVersion('pom.xml')}" def imageTag = "${env.BRANCH_NAME}-${getPomVersion('pom.xml')}"
if (env.BRANCH_NAME == 'master') { if (isMainBranch()) {
imageTag += "-${env.GIT_COMMIT.take(7)}" imageTag += "-${env.GIT_COMMIT.take(7)}"
} }
...@@ -174,9 +174,9 @@ Void configureGit() { ...@@ -174,9 +174,9 @@ Void configureGit() {
Void sendFailureMessage() { Void sendFailureMessage() {
def room = '' def room = ''
def data = """{"msgtype":"m.text", \ 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", \ "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') { if (env.BRANCH_NAME == 'main') {
room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de" room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de"
...@@ -193,3 +193,7 @@ String getElementAccessToken() { ...@@ -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 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'
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment