Sonarqube scans taking 30mins for every build in Jenkins step

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

I am using Community Edition - Version 9.0.1 (build 46107) ,
sonarqube scanner plugin jenkins 2.14

  • what are you trying to achieve

I have a step in Jenkins for sonarqube integration and it works but the builds are taking nearly 30mins each time.

My setup is Jenkins and Sonarqube deployed into Kubernetes using helm.

I’m thinking the issue is to do with caching.

  • what have you tried so far to achieve this

I’ve created a PV and PVC using azure file share and mounted that into the maven docker container that triggers the MVN sonar:sonar step.

I can see that the files are in the Azure file share.
but when I re-run the pipeline it analyze all 195 files again.

[INFO] 195 source files to be analyzed
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=33ms
[INFO] 0/195 files analyzed, current file: apiserver/src/main/java/file-----.java
[INFO] 1/195 file analyzed, current file: apiserver/src/main/java/file-----.java
[INFO] 3/195 files analyzed, current file: apiserver/src/main/java/file3-----.java
...........
..........
[INFO] 195/195 files analyzed, current file: apiserver/src/main/java/file195-----.java
[WARNING] Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
[INFO] Java "Main" source files AST scan (done) | time=1465001ms
[INFO] No "Test" source files to scan.
[INFO] No "Generated" source files to scan.
[INFO] Sensor JavaSensor [java] (done) | time=1469048ms
[INFO] Sensor CSS Rules [cssfamily]
......

My Jenkins step

stage("SonarQube Analysis") {
            steps {
                withSonarQubeEnv(installationName: 'sonar_token_access') {
                    container('maven') {
                        sh """
                            mvn sonar:sonar -Dsonar.scala.scoverage.disable=true -Dsonar.projectKey=projectKey -Dcalibrate-profile=${PROFILE} -Dsonar.login=$SONARQUBE_PROJECTS_TOKEN_ACCESS -Dsonar.projectName=${APPLICATION_NAME} -Dmaven.repo.local=$M2_REPOSITORY_DIR -s /usr/share/maven/ref/settings.xml
                        """
                    }
                }
            }
        }

Azure storage

image

Jenkins UI

Sonar plugin Jenkins

Hi,

Welcome to the community!

First, I need to drop a note that 9.0 isn’t supported; only the LTS (currently 8.9.7) and the latest versions (currently 9.3) are supported. You should upgrade. But it’s not likely to be relevant to your issue.

Well, yes… In that there’s no caching of analysis results. It’s something we’re looking at, but it’s not available for Java analysis yet.

That said, your analysis does seem to be running slowly. I would expect to see the status checkpoints in your log (“x/195 files analyzed”) moving faster than 1.5 files every… I believe it’s 20s.

Can you look at what resources are available to analysis? Make sure there’s e.g. enough memory?

 
Ann