Must-share information
-
which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
- SonarQube: Developer Edition Version 9.2.4 (build 50792)
- Scanner for Jenkins: 2.7
-
what are you trying to achieve
We would like to run multiple Sonarqube analyses and check the corresponding quality gate results in our monorepo projects.
We are aware that analyses in parallel is not yet supported by Scanner plugin at this point, ref: Sonarqube Scanner for Jenkins, analysis in parallel ? [SONARJNKNS-316]
Whereas sequantial analyses is supported per Sonarqube documentation:
Jenkins extension for SonarQube
If you want to run multiple analysis in the same pipeline and use waitForQualityGate you have to do everything in order
- what have you tried so far to achieve this
However, we noticed thatwaitForQualityGate
step still refres to the very first analysis task when there are multiple analyses in sequence. For example, with the following pipeline code:
pipeline {
agent none
stages {
stage("matrix: build & test") {
matrix {
axes {
axis {
name "APP_NAME"
values "project_A", "project_B" // etc
}
}
agent {
kubernetes {
// cloud k8s definitions
}
}
stages("build -> test -> stash") {
stage('build') {
// build gradle project in parallel
sh('gradlew -p ${APP_NAME} clean build test')
// stash built project for sonar stages
stash "built_project_${APP_NAME}"
}
}
}
}
stage("sequential: sonar") {
agent {
kubernetes {
// cloud k8s definitions
}
}
stages {
stage("SonarQube - Project_A") {
steps {
unstash "built_project_Project_A"
container('jdk11') {
withCredentials([]) {
withSonarQubeEnv() {
sh "gradlew -p Project_A sonarqube"
}
}
}
}
}
stage("QG - Project_A") {
steps {
waitForQualityGate abortPipeline: false
}
}
stage("SonarQube - Project_B") {
steps {
unstash "built_project_Project_B"
container('jdk11') {
withCredentials([]) {
withSonarQubeEnv() {
sh "gradlew -p Project_B sonarqube"
}
}
}
}
}
stage("QG - Project_B") {
steps {
waitForQualityGate abortPipeline: false
}
}
}
}
}
}
I can see that sonarqube analyze generated two different task IDs correctly, but only the first task was picked up by waitForQualityGate
. Resulting in the same quality gate result being referred twice.
I am curious if it’s due to the plugin version currently used by our infrastructure team being too old, or a bug/limitation from the scanner for multiple analyses in general (not limited to parallel execution).