Only PR analysis failing with error: java.lang.UnsupportedOperationException

07:55:38  07:55:38.197 WARN: File '/opt/workDir/***.spec.ts' was detected as changed but without having changed lines
07:55:38  07:55:38.197 WARN: File '***.ts' was detected as changed but without having changed lines
07:55:38  07:55:38.203 DEBUG: eslint-bridge server will shutdown
07:55:44  07:55:43.204 DEBUG: eslint-bridge server closed
07:55:44  07:55:43.205 INFO: Time spent writing ucfgs 0ms
07:55:44  07:55:44.639 INFO: ------------------------------------------------------------------------
07:55:44  07:55:44.639 INFO: EXECUTION FAILURE
07:55:44  07:55:44.639 INFO: ------------------------------------------------------------------------
07:55:44  07:55:44.640 INFO: Total time: 3:43.860s
07:55:44  07:55:44.745 ERROR: Error during SonarScanner execution
07:55:44  07:55:44.745 INFO: Final Memory: 54M/208M
07:55:44  07:55:44.745 INFO: ------------------------------------------------------------------------
07:55:44  java.lang.UnsupportedOperationException
07:55:44  	at java.base/java.util.AbstractCollection.add(AbstractCollection.java:267)
07:55:44  	at org.sonar.scanner.report.ChangedLinesPublisher.writeChangedLines(ChangedLinesPublisher.java:93)
07:55:44  	at org.sonar.scanner.report.ChangedLinesPublisher.publish(ChangedLinesPublisher.java:65)
07:55:44  	at org.sonar.scanner.report.ReportPublisher.generateReportFile(ReportPublisher.java:181)
07:55:44  	at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:154)
07:55:44  	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:430)
07:55:44  	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
07:55:44  	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
07:55:44  	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:130)
07:55:44  	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
07:55:44  	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
07:55:44  	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
07:55:44  	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
07:55:44  	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
07:55:44  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
07:55:44  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
07:55:44  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
07:55:44  	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
07:55:44  	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
07:55:44  	at com.sun.proxy.$Proxy0.execute(Unknown Source)
07:55:44  	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
07:55:44  	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
07:55:44  	at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
07:55:44  	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
07:55:44  	at org.sonarsource.scanner.cli.Main.main(Main.java:62)

Hey there.

What DevOps platform are you using to run the analysis? Can you share your pipeline configuration?

Hi @Colin
We are using Jenkins Multibranch Pipeline job

@Colin
the cli command looks like this

sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=dev-bitbucket -Dsonar.projectBaseDir=./*** -Dproject.settings=./sources/sonar-project.properties -Dsonar.scanner.metadataFilePath=$(pwd)/report-task.txt -Dsonar.ws.timeout=600 -Dsonar.projectKey=dev-test -Dsonar.pullrequest.branch=feature-A -Dsonar.pullrequest.key=103 -Dsonar.pullrequest.base=develop -Dsonar.login=****'\

And tried all the strategies in Jenkins multibranch pipeline job

Determines how pull requests are discovered:
**Merging the pull request with the current target branch revision**
Discover each pull request once with the discovered revision corresponding to the result of merging with the current revision of the target branch
**The current pull request revision**
Discover each pull request once with the discovered revision corresponding to the pull request head revision without merging
**Both the current pull request revision and the pull request merged with the current target branch revision**
Discover each pull request twice. The first discovered revision corresponds to the result of merging with the current revision of the target branch in each scan. The second parallel discovered revision corresponds to the pull request head revision without merging

Hi @Colin
Did you get chance to look into it?

HI @js-techie,

Can I check if the pipeline was previously working and this is a recent issue or if you are trying to setup a new pipeline?

It might also be useful if you could run the command with debug-level logging (you can see more information about this here: SonarCloud-CI)

Also, I assume that the previously mentioned command is recieving those values as variables from the Jenkins job? I notice that you dont have a project specified however, is this information held inside of the Sonar-project.properties file?

Finally, do you also have a SONAR_TOKEN for the connection? This would have probably been setup as part of the initial import.

Hi @shane.findley
We are using multibranchpipeline job, the configuration is same of all of the branch pipelines.
When we create a pull request a new pipeline will be created, here we facing this issue. not yet succeeded.
yes we have Sonar-project.properties in every branch.
Yes we have SONAR_TOKEN

I Could see lot of lines in the console output with some warning

WARN: File '/home/jenkins/sources/.spec.ts' was detected as changed but without having changed lines

we have sonar.exclusions=, sonar.coverage.exclusions defined in Sonar-project.properties file

Ok so it sounds like you have most of the settings which we would expect for this to run properly, you have said that PRs are failing, however, are branches also failing or is it only limited to PRs?

I have a couple of questions to try and see if we can find the cause of this issue.

I noticed that in the above comments, your project key is mentioning bitbucket. Can I check how the project was actually imported? I’m thinking that there could potentially be an issue with picking up the PR information from Bitbucket depending on how the project was imported.

I also found the following information in the CLI documentation, which details that it shouldn’t be possible to use the projectBaseDir and project.settings parameters at the same time. Do you know why both of these parameters are being passed to the CLI?

Alternatives to the sonar-project.properties file

If the sonar-project.properties file cannot be created in the root directory of the project, the alternatives are:

  • The properties can be specified directly through the command line. Ex:
sonar-scanner -Dsonar.organization=my_organization -Dsonar.projectKey=my_project -> Dsonar.sources=src
  • The property project.settings can be used to specify the path to the project configuration file (this option is incompatible with the sonar.projectBaseDir.property).
  • The root folder of the project to analyze can be set through the sonar.projectBaseDir property. This folder must contain a sonar-project.properties file if the sonar.projectKey is not specified on the command line. Additional analysis parameters can be defined in this project configuration file or through command line parameters.

Hi @shane.findley
Project was imported using sonarcloud ui
Below method:

Hi @js-techie,

I believe that we have managed to isolate an issue on the SonarCloud code base which could be causing this issue that you are experiencing. I will keep you updated on the progress and I hope that it will resolve the issue which you are experiencing.

Thanks for the Update @shane.findley

Hi @shane.findley
Any Update on this?

Hi @js-techie,

Sorry for the delay, I have just checked and the fix is currently being held as it needs some proof as to where the issue is coming from. Do you have a recent failure log that you could send to me, I might be able to link the two which would allow the fix to progress.

Hi @js-techie,

The changes have been prepped for release and should be part of the coming release in the next few days. I will follow this up with another message to confirm that it is available, I hope that this will remove the issues that you are facing.

Hi @js-techie ,

These changes should be available now, I hope that this helps to resolve the issues which you are experiencing.

Hi @shane.findley
Thanks for the support.
We will monitor our builds for few days and update you

1 Like

Hi @shane.findley,
I am also from same team of js-techie.
Now we are facing an issue that our PR anaylsis coverage is not showing in sonarcloud which is saying 0 new lines to cover even their are some changes in code. And for same branch analysis it is working fine. I created a separate topic for same issue Code Coverage is not generating only for PR Analysis of Javascript Project

PFA SS below

Hi @Viswa658 ,

I will discuss with Colin about this one to see what we can do. However, as it is a different topic I’ll reply over there rather than having the two tickets running.