Skip to content

Commit f9eb6af

Browse files
committed
Don't provide a SonarQube target branch when analyzing the main branch
QA-2475
1 parent 72a3859 commit f9eb6af

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Jenkinsfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pipeline {
4444
}
4545
steps {
4646
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
47-
sh 'mvn compile test-compile'
47+
sh 'mvn compile test-compile package -Dmaven.test.skip=true -Dmaven.javadoc.failOnError=false'
4848
}
4949
}
5050
}
@@ -53,12 +53,13 @@ pipeline {
5353
timeout(time: 30, unit: 'MINUTES')
5454
}
5555
environment {
56-
SONAR_BRANCH_TARGET= sh (returnStdout: true, script: '[ $BRANCH_NAME = master ] && echo master || echo develop').trim()
56+
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()
57+
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()
5758
}
5859
steps {
5960
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
6061
withSonarQubeEnv('Sonar') {
61-
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 -Dsonar.branch.name="${BRANCH_NAME}" -Dsonar.branch.target="${SONAR_BRANCH_TARGET}"'
62+
sh 'mvn --activate-profiles test org.jacoco:jacoco-maven-plugin:prepare-agent org.jacoco:jacoco-maven-plugin:report verify -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.test.skip=false -Dmaven.test.failure.ignore=false -Dmaven.javadoc.skip=true sonar:sonar "${SONAR_BRANCH_NAME}" "${SONAR_BRANCH_TARGET}"'
6263
}
6364
}
6465
}
@@ -108,7 +109,7 @@ pipeline {
108109
timeout(time: 5, unit: 'MINUTES')
109110
}
110111
steps {
111-
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.jar'
112+
archiveArtifacts allowEmptyArchive: true, artifacts: 'target/*.jar, target/*.pom', excludes: '**/fb-contrib-*.jar, **/findsecbugs-plugin-*.jar'
112113
}
113114
}
114115
}

0 commit comments

Comments
 (0)