I’m trying to setup sonarcloud for the Infinitest project with Github actions.
I’ve created a sonarcloud organization but I struggle to setup the analysis through a Github action workflow. The changes are here
From what I can see in the logs the build seems to work fine and the analysis as well, but (I think) it fails to upload the analysis.
I’ve checked that the token I’m using works by running an analysis from my computer (it worked) and I’ve used that token in the SONAR_TOKEN secret.
Note that maven runs in xvfb because it needs an X11 environment.
After solving various problems with my setup I’m running out of ideas for this error:
[INFO] CPD Executor 97 files had no CPD blocks
[INFO] CPD Executor Calculating CPD for 148 files
[INFO] CPD Executor CPD calculation finished (done) | time=37ms
[INFO] SCM writing changed lines
[INFO] SCM writing changed lines (done) | time=32ms
[INFO] Analysis report generated in 2249ms, dir size=466 KB
[INFO] Analysis report compressed in 310ms, zip size=338 KB
[INFO] Closing heartbeat service
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Infinitest Parent POM 5.3.2-SNAPSHOT:
[INFO]
[INFO] Infinitest Parent POM .............................. FAILURE [ 46.896 s]
[INFO] Infinitest Runner .................................. SUCCESS [ 10.637 s]
[INFO] Infinitest ClassLoader ............................. SUCCESS [ 0.050 s]
[INFO] Infinitest Lib ..................................... SUCCESS [ 15.245 s]
[INFO] Infinitest for IntelliJ ............................ SUCCESS [ 11.634 s]
[INFO] Infinitest Feature for Eclipse ..................... SUCCESS [ 0.014 s]
[INFO] Infinitest Plugin for Eclipse ...................... SUCCESS [ 20.441 s]
[INFO] infinitest-runner-test ............................. SUCCESS [ 1.280 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:48 min
[INFO] Finished at: 2022-08-28T15:11:49Z
[INFO] ------------------------------------------------------------------------
Error: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project infinitest-parent: closed -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project infinitest-parent: closed
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: closed
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute (ScannerBootstrapper.java:67)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute (SonarQubeMojo.java:108)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.IllegalStateException: closed
at okio.RealBufferedSource.select (RealBufferedSource.kt:220)
at okhttp3.internal.Util.readBomAsCharset (Util.kt:259)
at okhttp3.ResponseBody.string (ResponseBody.kt:187)
at org.sonarqube.ws.client.OkHttpResponse.content (OkHttpResponse.java:67)
at org.sonar.scanner.bootstrap.DefaultScannerWsClient.failIfUnauthorized (DefaultScannerWsClient.java:80)
at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call (DefaultScannerWsClient.java:61)
at org.sonar.scanner.report.ReportPublisher.upload (ReportPublisher.java:222)
at org.sonar.scanner.report.ReportPublisher.execute (ReportPublisher.java:159)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart (ProjectScanContainer.java:408)
at org.sonar.core.platform.ComponentContainer.startComponents (ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute (ComponentContainer.java:109)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart (GlobalContainer.java:130)
at org.sonar.core.platform.ComponentContainer.startComponents (ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute (ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute (Batch.java:58)
at org.sonar.batch.bootstrapper.Batch.execute (Batch.java:52)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute (BatchIsolatedLauncher.java:46)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke (IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy50.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.maven.bootstrap.ScannerBootstrapper.execute (ScannerBootstrapper.java:65)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute (SonarQubeMojo.java:108)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Error:
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Error: Process completed with exit code 1.
Hi Colin, thanks for looking into this!
The successful analysis on my (windows) computer was without xvfb, I simply used maven
I tried running the workflow on windows so I don’t have to use xvbf and modified my build to:
I’m not sure what is the problem because the error message is not super clear.
Would you know if it might mean that the sonar token is not set correctly?
Initially I was trying to setup sonarcloud in a pull request from a forked repo, but then I understood that in that case the secrets are not accesible. So I switched to a branch on the base repo and now I got out of ideas
You should, of course, make sure the token is correct and that the user it was generated for has Execute Analysis permissions – and, I would expect a different error message if the token isn’t valid.
Could you try adding -X to your Maven command to see if there’s anything more interesting in logs at the Debug level?
Hi Colin,
I’ve contacted the former maintainer of the project and got me access to the sonarcloud org he had created a while ago.
After updating the sonar.organization property from infinitest-github to infinitest and creating a new token the build worked.
So I think the build was fine and the issue was in the infinitest-github, maybe in the way the permissions were configured?
I think I’ll delete the infinitest-github org, unless you need it to investigate the problem?
I’m reaching out to you to provide you with some details related to the analysis failure on the 29th of August. The reason was that you hit the limit of submission per user/token so that’s why a new token solved the issue.
Thanks a lot for getting back to me @Nawar_Hamo
I tried again today on the infinitest-github org and got the same error:
Caused by: java.lang.IllegalStateException: closed
at okio.RealBufferedSource.select (RealBufferedSource.kt:220)
at okhttp3.internal.Util.readBomAsCharset (Util.kt:259)
at okhttp3.ResponseBody.string (ResponseBody.kt:187)
at org.sonarqube.ws.client.OkHttpResponse.content (OkHttpResponse.java:67)
at org.sonar.scanner.bootstrap.DefaultScannerWsClient.failIfUnauthorized (DefaultScannerWsClient.java:80)
at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call (DefaultScannerWsClient.java:61)
at org.sonar.scanner.report.ReportPublisher.upload (ReportPublisher.java:222)
at org.sonar.scanner.report.ReportPublisher.execute (ReportPublisher.java:159)
I did not run any other analysis today so I’m surprised that the issue would be a limit. Or maybe the limit is reset less frequently than daily?
I tried on the infinitest org with the same sonar token immediately after and was able to submit an analysis.
So the difference between the two is that commit: build: test changing the sonar org to infinitest-github · infinitest/infinitest@6374ce3 · GitHub
Maybe I was hitting the limit because I tried so many things but there’s also a problem with the infinitest-github org?
I would ask you to activate the debug mode in your maven run to get more information.
I need to understand what is happening and where is the issue exactly.
After checking from our side. you may have a permission issue on this project. Your project is not binding to the organization infinitest-github or you don’t have the right project key associated (maybe this project is still associated to infinitest).
I suggest you check your configuration to make sure that the project key is binding to the right organization and try again. I suggest also closing this thread because the main issue was not related.
Please do not hesitate to open a new thread if you still have the issue then.
Thanks again @Nawar_Hamo, I think the issue is with the project key and your message gave me the clue I missed.
Here are some assumptions I made that turned out to be incorrect, please don’t hesitate to correct me if I got it wrong again!
Incorrect assumptions I had:
When onboarding a Github project, sonarcloud uses the maven groupId:artifactId as project key (wrong: not sure how it’s generated) so you can omit the project key and it will use the default for maven projects
The project key identifies a project within an organization (wrong: the project key seems to be globally unique so two projects from different orgs cannot have the same project key)
When doing a Pull Request from a forked repo Github Actions will use the SONAR_TOKEN secret of the forked repo (wrong: pull requests from forked repos cannot use either the SONAR_TOKEN secret of the main repo or the forked repo)
So in the end it was user error but I wish that sonarcloud could return clearer error messages. For the last error I made (unrelated project and org keys) there’s simply no error message