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 {
}
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'
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment