Skip to content

Commit

Permalink
add set sonarqube addons tag step
Browse files Browse the repository at this point in the history
refactor post step - add clean, send email to committer
Refs #135777
  • Loading branch information
valentinab25 committed Jul 5, 2021
1 parent 6ee8c27 commit db7fbf1
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pipeline {
RANCHER_ENVID = "1a332957"
dockerImage = ''
tagName = ''
SONARQUBE_TAG = ""
}

stages {
Expand Down Expand Up @@ -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()
Expand All @@ -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 = """<h1>${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${status}</h1>
<p>Check console output at <a href="${url}">${env.JOB_BASE_NAME} - #${env.BUILD_NUMBER}</a></p>
def details = """<h1>${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${currentBuild.currentResult}</h1>
<p>Check console output at <a href="${env.BUILD_URL}/display/redirect">${env.JOB_BASE_NAME} - #${env.BUILD_NUMBER}</a></p>
"""

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']]
)
}
}
}
Expand Down

0 comments on commit db7fbf1

Please sign in to comment.