Could not able to push the results to the Sonarcloud.io

I’m trying to decorate Bitbucket for every commit and pull request.

I’ve created a new branch (Test) and wrote the Bitbucket-pipelines.yml file to build the project (Maven build), the build was successful but the results are not being pushed to Sonarcloud.io

My yml file have the following template which is similar to this:

https://bitbucket.org/sonarsource/sample-maven-project/src/master/bitbucket-pipelines.yml

Note:

  1. We have created the project in sonarcloud.io with the same project name in Bitbucket 2) Declared both Sonartoken and its value in Bitbucket 3) Enabled pipeline in Bitbucket repo settings.

Any pointers would be helpful

Hi @Sudhir,

In order to help you can you clarify the following points :

  • How have you created your project in SonarCloud? manually or importing from a BBC repository like this
  • Were you able to first analyse your default branch (master or develop) ?
  • Do you have any error you could share in the pipeline in BBC or in the background tasks in SonarCloud?

Thanks,
Cheers

Hi @aurelie,

  1. The project was not created manually.
  2. I did not analyse the master branch prior. I’ve created a branch called ‘test’ from master branch and committed the Bitbucket-pipelines.yml in the ‘test’ branch and did the Pipeline run
  3. There are no errors while or during the course of running the Pipeline (Which is what I’m bothered about). Yet I could not able to view the Analysis on Sonarcloud

Thank you,

Correction:

I am only using :

‘mvn - B verify’ command in the Pipeline script

Thank you,

In this case, I think there are 2 things:

  1. Our bitbucket-pipelines.yml example is configured to analyse only pull-requests and master branch on SC
    image

Did you remove the sonar plugin in the &build-test-sonarcloud step? If yes, it is actually the plugin that will launch the analysis and send the results to SC, if you remove it, the analysis won’t be pushed to SC.
It is also a step in the project onboarding


May I ask you why did you remove it, or if you missed it in the onboarding? We may have missed a use case and would be able to improve if needed :slight_smile:

To sum up, put back the sonar plugin if you removed it in the SC step, add some code that is different from your master in your test branch, create a PR for your test branch and hopefully you’ll see results for your PR in SC :slight_smile:

Cheers

Hey @aurelie ,

Thanks for your input. Finally there is someone who is trying to help me :slight_smile:

Coming to the topic:

  1. Oh yes, you are right. I have missed his point somehow. I will replace the master branch and try to put the branch where i’m working on.

  2. Yes, i have removed the ’ org.jacoco:jacoco-maven-plugin:prepare-agent verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar’ intentionally as this is resulting in build failure (I wasn’t aware that this is preventing us to push the results to SC)

Following is the error which i’m facing while using the above command :

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project : Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar failed: Plugin org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746 or one of its dependencies could not be resolved: Failed to collect dependencies at org.sonarsource.scanner.maven:sonar-maven-plugin:jar:3.7.0.1746 -> org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4: Failed to read artifact descriptor for org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4: Could not transfer artifact org.sonatype.plexus:plexus-sec-dispatcher:pom:1.4 from/to central (https://repo..**.org/maven2): Connection reset -> [Help 1]

In order to prevent this error, i had to remove the initial command. Can you please help me/describe what is actually causing this error? how can we prevent this error and publish the code results to SC successfully?

Or

If we cannot able to resolve the above error , can we do static code analysis in bitbucket for a maven project without actually building the project (In worst case)

Thank you, :slight_smile:

Hello @Sudhir,

The org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4 is a dependency of our sonar-scanner, and the error states that this dependency could not be downloaded. The connection reset part leads me to believe that it might be a one-off error. Do you get the same error every time you try to execute the scanner? The dependency is available on maven central.

We are not able to analyse Java code without access to the byte code, so you will always have to build the project.

Hope that helps,
Tom

1 Like