Skip to content
Snippets Groups Projects
Commit db17878c authored by OZGCloud's avatar OZGCloud
Browse files

OZG-3140 jenkinsfile new jenkins

parent 43f15e9b
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ pipeline { ...@@ -8,7 +8,7 @@ pipeline {
} }
environment { environment {
BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/blue/organizations/jenkins/kop-common/detail/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/pipeline" BLUE_OCEAN_URL = "https://jenkins.ozg-sh.de/job/kop-common/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/
} }
...@@ -110,10 +110,33 @@ pipeline { ...@@ -110,10 +110,33 @@ pipeline {
post { post {
failure { failure {
script { script {
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'release') {
sendFailureMessage()
}
}
}
}
}
Void sendFailureMessage() {
def room = ''
def data = """{"msgtype":"m.text", \
"body":"kop-common: Build Failed. Stage: ${FAILED_STAGE} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}", \
"format": "org.matrix.custom.html", \
"formatted_body":"kop-common: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>"}"""
if (env.BRANCH_NAME == 'master') { if (env.BRANCH_NAME == 'master') {
//slackSend(color: "danger", message: "Kop-Common: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <${BLUE_OCEAN_URL}|${env.BUILD_NUMBER}>") room = "!iQPAvQIiRwRpNOszjw:matrix.ozg-sh.de"
} }
else if (env.BRANCH_NAME == 'release') {
room = "!oWZpUGTFsxkJIYNfYg:matrix.ozg-sh.de"
} }
sh "curl -XPOST -H 'authorization: Bearer ${getElementAccessToken()}' -d '${data}' https://matrix.ozg-sh.de/_matrix/client/v3/rooms/$room/send/m.room.message"
} }
String getElementAccessToken() {
withCredentials([string(credentialsId: 'element-login-json', variable: 'LOGIN_JSON')]) {
return readJSON ( text: sh (script: '''curl -XPOST -d \"$LOGIN_JSON\" https://matrix.ozg-sh.de/_matrix/client/v3/login''', returnStdout: true)).access_token
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment