Issue with running SonarQubeAnalyze@5 task in YAML pipeline

Hi.
I’ve got a yaml pipeline that builds .NET code without errors.
I’m also trying to run Sonar scanner and push the report to our self-hosted SQ server.

  • task: SonarQubePrepare@5
    inputs:
    SonarQube: ‘assets-sonarqube’
    scannerMode: ‘MSBuild’
    projectKey: ‘service-name’

  • task: SonarQubeAnalyze@5

The first tasks completes successfully.
The second one fails with the following output. Looks like it is an internal SQ error.
Is this something you can help me with?
Thanks.


2022-07-04T12:51:06.8665904Z INFO: Importing results from 5 proto files in ‘/workspace/3/.sonarqube/out/2/output-cs’
2022-07-04T12:51:06.9355824Z INFO: Importing results from 5 proto files in ‘/workspace/3/.sonarqube/out/11/output-cs’
2022-07-04T12:51:06.9417278Z INFO: Importing results from 5 proto files in ‘/workspace/3/.sonarqube/out/3/output-cs’
2022-07-04T12:51:06.9492094Z INFO: Importing results from 5 proto files in ‘/workspace/3/.sonarqube/out/8/output-cs’
2022-07-04T12:51:07.0489164Z INFO: ------------------------------------------------------------------------
2022-07-04T12:51:07.0491306Z INFO: EXECUTION FAILURE
2022-07-04T12:51:07.0492954Z INFO: ------------------------------------------------------------------------
2022-07-04T12:51:07.0576397Z INFO: Total time: 16.867s
2022-07-04T12:51:07.1874565Z INFO: Final Memory: 14M/49M
2022-07-04T12:51:07.1968284Z INFO: ------------------------------------------------------------------------
2022-07-04T12:51:07.1995710Z ##[error]ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Cannot register highlighting rule for characters at Range[from [line=57, lineOffset=113] to [line=57, lineOffset=117]] as it overlaps at least one existing rule
at org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting.checkOverlappingBoundaries(DefaultHighlighting.java:60)
at org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting.doSave(DefaultHighlighting.java:120)
at org.sonar.api.batch.sensor.internal.DefaultStorable.save(DefaultStorable.java:45)
at org.sonarsource.dotnet.shared.plugins.protobuf.HighlightImporter.save(HighlightImporter.java:73)
at org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.importResults(ProtobufDataImporter.java:78)
at org.sonarsource.dotnet.shared.plugins.DotNetSensor.executeInternal(DotNetSensor.java:98)
at org.sonarsource.dotnet.shared.plugins.DotNetSensor.execute(DotNetSensor.java:71)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ProjectSensorsExecutor.execute(ProjectSensorsExecutor.java:49)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:361)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Hello

Are you running msbuild between the Prepare and the Analyze tasks?

See

  • Add a new Run Code Analysis task after your build task.

in Azure DevOps Integration | SonarQube Docs

That’s right.

What version of SQ are you using?

Can you please share the verbose logs?

Here is the log of SQ Analyze

SQ-error.txt (32.5 KB)

SQ server version: 8.5.1.38104

Hi @nomad0369 - you are using an unsupported version of SonarQube - could you please first update to a supported version?

We’ve had a bug that was causing this in the past and we’ve fixed it. Please update to the latest SQ version.

I’ve upgraded SQ version to 8.9.9.
Unfortunately, I still see the same error.

We’ve also got a number of plugins. Could any of them cause such an issue?

sonar-groovy-plugin-1.6-RC1.jar
sonar-yaml-plugin-1.5.1.jar
sonar-auth-aad-plugin-1.2.0.jar
sonar-sonargraph-plugin-3.5.jar
sonar-issueresolver-plugin-1.0.2.jar
checkstyle-sonar-plugin-8.35.jar
sonar-dependency-check-plugin-2.0.6.jar

##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
##[error]java.lang.IllegalStateException: Cannot register highlighting rule for characters at Range[from [line=57, lineOffset=113] to [line=57, lineOffset=117]] as it overlaps at least one existing rule
java.lang.IllegalStateException: Cannot register highlighting rule for characters at Range[from [line=57, lineOffset=113] to [line=57, lineOffset=117]] as it overlaps at least one existing rule
##[error]at org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting.checkOverlappingBoundaries(DefaultHighlighting.java:60)
at org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting.doSave(DefaultHighlighting.java:120)
at org.sonar.api.batch.sensor.internal.DefaultStorable.save(DefaultStorable.java:45)
at org.sonarsource.dotnet.shared.plugins.protobuf.HighlightImporter.save(HighlightImporter.java:73)
at org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.importResults(ProtobufDataImporter.java:79)
at org.sonarsource.dotnet.shared.plugins.DotNetSensor.importResults(DotNetSensor.java:101)
at org.sonarsource.dotnet.shared.plugins.DotNetSensor.execute(DotNetSensor.java:81)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ProjectSensorsExecutor.execute(ProjectSensorsExecutor.java:49)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:360)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Thanks.

Is any of this plugin analyzing C# code and generating Highlighting metrics?

I might be able to answer that question based on debug logs. Could you please provide the debug logs of the analysis (“SQ Analyze”)? You need to pass a parameter during the begin step to do that (the previous logs you gave me were INFO-level, I need DEBUG level).

SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true

or

      - task: SonarQubePrepare@1
        displayName: 'Code Analysis - Begin'
        inputs:
          ...
          extraProperties: |
            sonar.verbose=true

Thanks!

Logs of the debug run.
This is the run of SQ without any plugins.
SQ-debug-log.txt (296.5 KB)

Thanks.

Hello @nomad0369

I’m afraid I cannot tell a lot from the logs. Would it be possible to share a reproducer project with us?

I’ve sent you a private message - only you can access it here: https://community.sonarsource.com/t/re-issue-with-running-sonarqubeanalyze-5-task-in-yaml-pipeline/69202

And also could you please share the .sonarqube\ folder (archive it, ZIP please) which is created in the root folder where you do the analysis from