From db7fbf103f4d6f38c9a391c334dabeb3cc3c3087 Mon Sep 17 00:00:00 2001 From: valentinab25 <30239069+valentinab25@users.noreply.github.com> Date: Mon, 5 Jul 2021 20:38:31 +0300 Subject: [PATCH] add set sonarqube addons tag step refactor post step - add clean, send email to committer Refs #135777 --- Jenkinsfile | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0288fc28..1acd8c8f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,6 +10,7 @@ pipeline { RANCHER_ENVID = "1a332957" dockerImage = '' tagName = '' + SONARQUBE_TAG = "" } stages { @@ -84,6 +85,25 @@ pipeline { } } + stage('Update SonarQube Tags') { + when { + not { + environment name: 'SONARQUBE_TAG', value: '' + } + buildingTag() + } + steps{ + node(label: 'docker') { + withSonarQubeEnv('Sonarqube') { + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GIT_TOKEN')]) { + sh '''docker pull eeacms/gitflow''' + sh '''docker run -i --rm --name="${BUILD_TAG}-sonar" -e GIT_NAME=${GIT_NAME} -e GIT_TOKEN="${GIT_TOKEN}" -e SONARQUBE_TAG=${SONARQUBE_TAG} -e SONARQUBE_TOKEN=${SONAR_AUTH_TOKEN} -e SONAR_HOST_URL=${SONAR_HOST_URL} eeacms/gitflow /update_sonarqube_tags.sh''' + } + } + } + } + } + stage('Upgrade demo') { when { buildingTag() @@ -102,23 +122,21 @@ pipeline { } post { + always { + cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true) + } changed { script { - def url = "${env.BUILD_URL}/display/redirect" - def status = currentBuild.currentResult - def subject = "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'" - def summary = "${subject} (${url})" - def details = """

${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${status}

-

Check console output at ${env.JOB_BASE_NAME} - #${env.BUILD_NUMBER}

+ def details = """

${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${currentBuild.currentResult}

+

Check console output at ${env.JOB_BASE_NAME} - #${env.BUILD_NUMBER}

""" - - def color = '#FFFF00' - if (status == 'SUCCESS') { - color = '#00FF00' - } else if (status == 'FAILURE') { - color = '#FF0000' - } - emailext (subject: '$DEFAULT_SUBJECT', to: '$DEFAULT_RECIPIENTS', body: details) + emailext( + subject: '$DEFAULT_SUBJECT', + body: details, + attachLog: true, + compressLog: true, + recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'CulpritsRecipientProvider']] + ) } } }