Jenkins Scanner picking the wrong Task ID for gradle subproject scan

Must-share information (formatted with Markdown):

  • SonarQube 9.9.3 LTS, deployed with Helm
  • Gradle org.sonarqube version 3.3
  • Jenkins SonarQube Scanner Plugin version 2.13

I’m trying to get a Jenkins job scanning two gradle subprojects with separate project IDs, but the second waitForQualityGate seems to be picking up the task ID for the first scan instead of the second. I’m not sure what, if anything, that I’m doing wrong here.

Jenkinsfile snippet:

stage( 'Library Sonar Analysis' ) {
    when {
        not {
            branch 'main'
        }
    }
    steps {
        container("oe-mvn-${containerVersion}"){
            withSonarQubeEnv('SonarQube') {
                sh "./gradlew :systemadmin-library:sonarqube --info"
            }
        }
    }
}
stage( 'Library Sonar Quality Gate' ) {
    when {
        not {
            branch 'main'
        }
    }
    steps {
        timeout(5) {
            waitForQualityGate abortPipeline: true
        }
    }
}
stage( 'Web Sonar Analysis' ) {
    when {
        not {
            branch 'main'
        }
    }
    steps {
        container("oe-mvn-${containerVersion}"){
            withSonarQubeEnv('SonarQube') {
                sh "./gradlew :systemadmin-web:sonarqube --info"
            }
        }
    }
}
stage( 'Web Sonar Quality Gate' ) {
    when {
        not {
            branch 'main'
        }
    }
    steps {
        timeout(5) {
            waitForQualityGate abortPipeline: true
        }
    }
}

Scan 1 Logs (trimmed):

Analysis report generated in 383ms, dir size=2.8 MB
Analysis report compressed in 918ms, zip size=1.1 MB
Analysis report uploaded in 77ms
ANALYSIS SUCCESSFUL, you can find the results at: https://<host>/dashboard?id=OBP.systemadmin%3ASystemAdminLibrary
Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
More about the report processing at https://<host>/api/ce/task?id=AYxkNCxZED7mb5-i2JE5
Analysis total time: 58.423 s
:systemadmin-library:sonarqube (Thread[Daemon worker,5,main]) completed. Took 1 mins 8.925 secs.

BUILD SUCCESSFUL in 2m 20s
7 actionable tasks: 4 executed, 3 up-to-date

Scan 1 Quality Gate:

Checking status of SonarQube task 'AYxkNCxZED7mb5-i2JE5' on server 'SonarQube'
SonarQube task 'AYxkNCxZED7mb5-i2JE5' status is 'IN_PROGRESS'
SonarQube task 'AYxkNCxZED7mb5-i2JE5' status is 'SUCCESS'
SonarQube task 'AYxkNCxZED7mb5-i2JE5' completed. Quality gate is 'OK'

Scan 2 Logs (trimmed):

Analysis report generated in 200ms, dir size=717.1 kB
Analysis report compressed in 181ms, zip size=182.8 kB
Analysis report uploaded in 33ms
ANALYSIS SUCCESSFUL, you can find the results at: https://<host>/dashboard?id=OBP.systemadmin%3ASystemAdminWeb
Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
More about the report processing at https://<host>t/api/ce/task?id=AYxkNO04ED7mb5-i2JE6
Analysis total time: 29.849 s
:systemadmin-web:sonarqube (Thread[Daemon worker,5,main]) completed. Took 31.719 secs.

BUILD SUCCESSFUL in 39s
14 actionable tasks: 3 executed, 11 up-to-date

Scan 2 Quality Gate:

Checking status of SonarQube task 'AYxkNCxZED7mb5-i2JE5' on server 'SonarQube'
SonarQube task 'AYxkNCxZED7mb5-i2JE5' status is 'SUCCESS'
SonarQube task 'AYxkNCxZED7mb5-i2JE5' completed. Quality gate is 'OK'

Hey there.

This thread sounds similar. Can you take a look?

Yes, that works! Thanks for your help.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.