Skip to content

Commit 158e496

Browse files
committed
Refactor Jenkinsfile
QA-2471
1 parent 358bf1e commit 158e496

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Jenkinsfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
@Library('pipeline-library')_
33

44
def schedule = env.BRANCH_NAME.contains('master') ? '@monthly' : env.BRANCH_NAME == 'develop' ? '@midnight' : ''
5+
def sonarBranchName = env.BRANCH_NAME.contains('master') ? '-Dsonar.branch.name=master' : '-Dsonar.branch.name=' + env.BRANCH_NAME
6+
def sonarBranchTarget = env.BRANCH_NAME.contains('master') ? '' : env.BRANCH_NAME == 'develop' ? '-Dsonar.branch.target=master' : '-Dsonar.branch.target=develop'
57

68
pipeline {
79

@@ -55,14 +57,10 @@ pipeline {
5557
options {
5658
timeout(time: 30, unit: 'MINUTES')
5759
}
58-
environment {
59-
SONAR_BRANCH_NAME = sh(returnStdout: true, script: '[ $BRANCH_NAME = master ] && echo || [ $BRANCH_NAME = develop ] && echo -Dsonar.branch.name=develop || echo -Dsonar.branch.name=$BRANCH_NAME').trim()
60-
SONAR_BRANCH_TARGET = sh(returnStdout: true, script: '[ $BRANCH_NAME = master ] && echo || [ $BRANCH_NAME = develop ] && echo -Dsonar.branch.target=master || echo -Dsonar.branch.target=develop').trim()
61-
}
6260
steps {
6361
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
6462
withSonarQubeEnv('Sonar') {
65-
sh 'mvn --activate-profiles test verify -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.test.skip=false -Dmaven.test.failure.ignore=false -Dmaven.javadoc.skip=true org.jacoco:jacoco-maven-plugin:prepare-agent org.jacoco:jacoco-maven-plugin:report sonar:sonar "${SONAR_BRANCH_NAME}" "${SONAR_BRANCH_TARGET}"'
63+
sh 'mvn --activate-profiles test -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.test.skip=false -Dmaven.test.failure.ignore=false -Dmaven.javadoc.skip=true org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report sonar:sonar ' + sonarBranchName + ' ' + sonarBranchTarget
6664
}
6765
}
6866
}
@@ -135,14 +133,14 @@ pipeline {
135133
}
136134
fixed {
137135
script {
138-
if ((env.BRANCH_NAME == 'master') || (env.BRANCH_NAME == 'develop')) {
136+
if (env.BRANCH_NAME.contains('master') || (env.BRANCH_NAME == 'develop')) {
139137
slackNotifier("#ci", currentBuild.currentResult, "${env.BRANCH_NAME} - Back to normal")
140138
}
141139
}
142140
}
143141
regression {
144142
script {
145-
if ((env.BRANCH_NAME == 'master') || (env.BRANCH_NAME == 'develop')) {
143+
if (env.BRANCH_NAME.contains('master') || (env.BRANCH_NAME == 'develop')) {
146144
slackNotifier("#ci", currentBuild.currentResult, "${env.BRANCH_NAME} - First failure")
147145
}
148146
}

0 commit comments

Comments
 (0)