diff --git a/Jenkinsfile b/Jenkinsfile index edbc090e7df94a61838ca119fac3f2c88d4a9084..4c7cdeb5ae657df5a8295cc5b08735dcd8fa3ce7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,6 +21,8 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +@Library('shared-libs') _ + pipeline { agent { node { @@ -29,6 +31,7 @@ pipeline { } environment { + JENKINS_URL = "https://jenkins.infra.ozg-cloud.systems/job/codeSH_operator/job/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/" RELEASE_REGEX = /\d+.\d+.\d+/ SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/ FAILED_STAGE = "" @@ -207,6 +210,15 @@ pipeline { } } } + post { + failure { + script { + if (isMainBranch() || isReleaseBranch()) { + sendFailureMessage() + } + } + } + } } @@ -270,12 +282,6 @@ Boolean isReleaseBranch() { return env.BRANCH_NAME == 'release' } -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 - } -} - Void doDevRollout() { cloneGitopsRepo() setNewOperatorVersion('dev') @@ -404,3 +410,14 @@ Boolean matchRegexVersion(List versions, String regex) { return true } + +Void sendFailureMessage() { + def message = "Operator: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <a href='${JENKINS_URL}'>${env.BUILD_NUMBER}</a>" + + if (isMainBranch()){ + sendMatrixMessage.sendMessageToMasterRoom(message) + } + else { + sendMatrixMessage.sendMessageToReleaseRoom(message) + } +} \ No newline at end of file