Sonarcloud scan analysis says successful then analysis exits as failed

Every time we are running a bitbucket pipeline for one of our repos we are getting a sonarcloud scan failure. The thing is the anaysis is successful and the report shows passed, but then the scan shows failed at the end and “exit code = 1”.

Full logs attached.
logs.txt (196.3 KB)
Image of passed scan attached.

This appears to have happened since we’ve upgraded our sonarsource/sonarcloud-scan pipe to 1.4.0.

How do we overcome this? Are we missing something in the logs? Any questions please ask.

  • ALM used: Bitbucket Cloud
  • CI system used: Bitbucket Cloud
  • Languages of the repository: JavaScript
02:59:09.058 INFO: ANALYSIS SUCCESSFUL, you can find the results at:
02:59:09.058 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
02:59:09.058 INFO: More about the report processing at
02:59:09.063 DEBUG: Post-jobs : 
02:59:09.068 DEBUG: eslint-bridge server will shutdown
02:59:14.071 DEBUG: eslint-bridge server closed
02:59:14.634 INFO: Analysis total time: 30.106 s
02:59:14.636 INFO: ------------------------------------------------------------------------
02:59:14.636 INFO: ------------------------------------------------------------------------
02:59:14.637 INFO: Total time: 42.489s
02:59:14.722 INFO: Final Memory: 47M/180M
02:59:14.722 INFO: ------------------------------------------------------------------------
e[31m✖ SonarCloud analysis failed. (exit code = 1)e[0m
Searching for files matching artifact pattern .bitbucket/pipelines/generated/pipeline/pipes/**
Artifact pattern .bitbucket/pipelines/generated/pipeline/pipes/** matched 1 files with a total size of 189.1 KiB
Compressed files matching artifact pattern .bitbucket/pipelines/generated/pipeline/pipes/** to 22 KiB in 0 seconds
Uploading artifact of 22 KiB
Successfully uploaded artifact in 0 seconds

Has anyone encountered this before?

Hello @jimrEHG , could you please share with us your Bitbucket pipeline configuration? You have a successful analysis and this message seems to not come from the scanner, so i need to know how the exit code is evaluated. I also never had an exit code 1 from a successful analysis coming from the scanner, could you try to run the analysis locally to check if you get the exit code 1 as well?

Hi @Alexandre_Holzhey, I am now seeing this failure in another one of our pipelines for a different repository and the only commonality I can find is this

tee: /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/sonarsource/sonarcloud-scan/sonarcloud-scan.log: Permission denied

I have also attached the bitbucket pipeline configuration file for the original repository. I haven’t been able to run the analysis locally yet.
bitbucket-pipelines.txt (5.5 KB)

I noticed one line that stood out in the logs I shared above
/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/sonarsource/sonarcloud-scan/sonarcloud-scan.log: Permission denied

In our bitbucket-pipelines.yml folder there are multiple pipes that run.

  1. sonarcloud-scan
  2. deploy to lower env 1
  3. sonarcloud-scan
  4. deploy to lower env 2

The first run of sonarcloud-scan does not get the permissions issue above, but the second does. That led me down the path that this was a bitbucket pipelines issue and I found this thread on the atlassian forums: Solved: aws-lambda-deploy pipe how to fix aws-lambda-deplo...

For some reason running subsequent pipes that try to access the same directories can lead to permissions issues for those subsequent pipes.

The fix was to include a command in the script section to always remove the directory the pipe is trying to write to before the pipe runs.

  - rm -rf /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes
  - pipe: sonarsource/sonarcloud-scan:1.4.0

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.