From ab5fbccf146b2949cb06eba2eb594450e83e4699 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Mon, 11 Jan 2021 15:54:54 +0100 Subject: [PATCH] edit jenkins pipeline --- Jenkinsfile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index af25d4ba3..94972403f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,5 @@ +def FAILED_STAGE + pipeline { agent { node { @@ -5,14 +7,22 @@ pipeline { } } + environment { + BLUE_OCEAN_URL = "https://jenkins-dev-tools.apps.lab.okd.local/blue/organizations/jenkins/OZG%2Fintelliform-adapter/detail/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/pipeline" + } + options { timeout(time: 1, unit: 'HOURS') disableConcurrentBuilds() + buildDiscarder(logRotator(numToKeepStr: '5')) } stages { stage('build intelliform-adapter') { steps { + script { + FAILED_STAGE=env.STAGE_NAME + } container("maven"){ sh 'mvn --version' sh 'mvn clean install' @@ -28,6 +38,8 @@ pipeline { stage('openshift deploy') { steps { script { + FAILED_STAGE=env.STAGE_NAME + def pom = readMavenPom file: 'pom.xml' def version = pom.version @@ -39,9 +51,34 @@ pipeline { openshift.tag("if-adapter-builder:${env.BRANCH_NAME}-${version}", "sh-eingang-dev/if-adapter:${env.BRANCH_NAME}-${version}") } + + if (env.BRANCH_NAME == 'master') { + openshift.withProject('sh-eingang-dev') { + def dc = openshift.selector('deployments', 'if-adapter') + + dc.rollout().status() + } + } } } } } } + + post { + success { + script { + if (env.BRANCH_NAME == 'master') { + slackSend(color: "good", message: "Intelliform-Adapter: Build Succeeded. Build-ID: <${BLUE_OCEAN_URL}|${env.BUILD_NUMBER}>") + } + } + } + failure { + script { + if (env.BRANCH_NAME == 'master') { + slackSend(color: "danger", message: "Intelliform-Adapter: Build Failed. Stage: ${FAILED_STAGE} Build-ID: <${BLUE_OCEAN_URL}|${env.BUILD_NUMBER}>") + } + } + } + } } \ No newline at end of file -- GitLab