3

Maven Sonar scanner is taking a long time to download the plugins ( [INFO] Load/download plugins (done) | time=495872ms) approx. 9 mins every time a build is triggered. Also, the cache is not working as the builds are triggered on the cloud (Azure DevOps)) with an agentless/serverless architecture. What could be solutions to reduce this time that is built faster?

[INFO] User cache: /home/vsts/.sonar/cache
[INFO] SonarQube version: 7.9.1
[INFO] Default locale: "en", source code encoding: "UTF-8"
[INFO] Load global settings
[INFO] Load global settings (done) | time=1097ms
[INFO] Server id: #####-$$xxxxx$$$
[INFO] User cache: /home/vsts/.sonar/cache
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=211ms
[INFO] Load/download plugins (done) | time=495872ms
[INFO] Loaded core extensions: developer-scanner
hagarwal
  • 1,153
  • 11
  • 27

1 Answers1

0

You can build a self-hosted agent to run the pipeline. So that the plugins can be cached on the local agent machine. Refer to the detailed steps here to create self-hosted agent.

You can also manually download the plugin jars with its dependencies, and include them in the code repo. Then you can install them manually in your pipeline using a script task to run below commands: See here.

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

For example:

mvn install:install-file -Dfile=/plugins/sonar-maven-plugin-3.6.0.1398.jar -DgroupId=org.sonarsource.scanner.maven -DartifactId=sonar-maven-plugin -Dversion=3.6.0.1398 -Dpackaging=jar`

mvn install:install-file -Dfile=/plugins/sonar-scanner-api-2.12.0.1661.jar -DgroupId=org.sonarsource.scanner.api -DartifactId=sonar-scanner-api -Dversion=2.12.0.1661 -Dpackaging=jar

You can also try using maven-install-plugin in pom file to install the local jars. See this thread for more information.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43