✖ SonarCloud analysis failed

Hi @waleedmazhar,

From what I can see in your logs, it seems to be a larger project that is being analyzed. It may be that 2 GB of memory that you provide to your container is not enough. Have you tried to increase the memory? Does the same problem occur in the same place?

Cheers,

Hi @Nils_Werner

thank you for your reply. Yes our project is big, it is magneto. it total size is around 300mb

I am already using size: 2x in pipeline. Every time pipeline runs I got same error, it break on html, as mentioned in error message.

Any thoughts on it, how can we run it successfully.

Thanks in advance,

Hi @waleedmazhar,

With such a large project, it doesn’t seem surprising that 2GB is not enough to complete the analysis. Can you please try with increased memory? (4GB or even more)

Also, we just released a small change to the scan pipe, to print the exit code when the scanner process crashes. Please adjust your pipeline to use this new release, and let us know the exit code printed when the process is killed:

- pipe: sonarsource/sonarcloud-scan:1.2.2

This is unlikely to change anything though. Ultimately it looks like the scanner simply needs more memory to analyze such project, and if it cannot have enough, then the pipeline shoots it down.

Hi Janos,

After updating pipeline I got different error and increase memory to max that bitbucket pipelien provide e.g. 8GB

INFO: Sensor JavaScript analysis [javascript]
INFO: Deploying custom rules bundle jar:file:/root/.sonar/cache/89a79ed6219c43720f92a0780fe73b4c/sonar-securityjsfrontend-plugin.jar!/js-vulnerabilities-rules-1.0.0.tgz to /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/eslint-bridge-bundle/package/custom-rules4598013441502352460
INFO: 1351 source files to be analyzed
INFO: 0/1351 files analyzed, current file: js/tiny_mce/utils/validate.js
INFO: 6/1351 files analyzed, current file: common/js/ZeroClipboard.js
INFO: 19/1351 files analyzed, current file: common/js/jquery-ui.js
INFO: 19/1351 files analyzed, current file: common/js/jquery-ui.js
time="2021-04-23T13:42:05Z" level=error msg="error waiting for container: unexpected EOF"

Thanks for the update.

Do you see an exit code at the end? Something like this, with some number:

:heavy_multiplication_x: SonarCloud analysis failed. (exit code = 2)

In any case, regarding the last error message (error waiting for container: unexpected EOF), it looks like this is coming from the platform, so it would be best to ask Bitbucket about it.

@janos
thank you for reply. After increasing docker memory : 7128

I am getting this error

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 54:43.526s
INFO: Final Memory: 529M/1780M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: You're not authorized to run analysis. Please contact the project administrator.
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
✖ SonarCloud analysis failed. (exit code = 2)

thanks

It seems the SONAR_TOKEN is not configured correctly. This should be set as a repository, project, or workspace variable on GitHub. You can create tokens on SonarCloud, from your user’s profile, in Security.

@janos @Nils_Werner

Thank you for your help, pipeline is working fine now for both scanning and quality gate

but today I just got this error for quality gate

Status: Downloaded newer image for sonarsource/sonarcloud-quality-gate:0.1.4
..✖ Quality Gate failed: Could not fetch quality gate status: b'{"errors":[{"msg":"Analysis with id \'None\' is not found"}]}'

This could happen when the paid plan of your organization has expired, or the number of LOC has exceeded your license limit. Can you please check? See the Administration / Billing page of your organization on SonarCloud.

@janos
thanks for your constant help.

Today I got another error

INFO: Running symbolic analysis
/usr/bin/run-scanner.sh: line 26:    10 Killed                  sonar-scanner "${ALL_ARGS[@]}" 2>&1
        11 Done                    | tee "${SCANNER_REPORT}"
✖ SonarCloud analysis failed. (exit code = 137)

It looks like the platform has killed the scanner process. It would be best to ask Bitbucket about it.

A post was split to a new topic: Unable to execute SoanrScanner analysis, SocketTimeoutException

@waleedmazhar How many files do you have in this project, approximately, and what are the languages in it? If you have a lot of files, it can be understandable that a lot of memory is required. The memory needs also depend on the languages analyzed. Based on the basic statistics about the number of files per language, I can ask the language analyzer teams to see if the memory needs look suspicious.

@jonas we have approx 38500 files and it is mostly php, few html, js and css. Most of times it fail and very fewer times it successfully run.
If it is memory issue, it should fail all times.

Do you get inconsistent outcome (success ↔ out of memory) for the exact same code analyzed? That would be strange indeed.

It could be interesting to know the number of lines in the largest files analyzed. Can you please share such stats for each language analyzed? (Say, the number of lines in the top 3 php, few html, js and css.)

@janos max a file contain like is 800 while agv is 200. this is magento project.

INFO: Running symbolic analysis
/usr/bin/run-scanner.sh: line 26:    10 Killed                  sonar-scanner "${ALL_ARGS[@]}" 2>&1
        11 Done                    | tee "${SCANNER_REPORT}"
✖ SonarCloud analysis failed. (exit code = 137)
INFO: Analyzing 19381 ucfgs to detect vulnerabilities.
/usr/bin/run-scanner.sh: line 26:    11 Killed                  sonar-scanner "${ALL_ARGS[@]}" 2>&1
        12 Done                    | tee "${SCANNER_REPORT}"
✖ SonarCloud analysis failed. (exit code = 137)

Yesterday, 10 pull requests created only 2 has successful while all are failed with above mentioned message. We have plan to merge pull requests into master after we can see it pass all security checks. If this will work like that then how can we rely on it for our production system.

Thanks

How many lines of code in total do you estimate in this project?

Do you confirm that in your current configuration the scanner has 7G available memory in the container?

@janos

we have <= 100k lines of codes.

this is my pipeline config

clone:
  depth: full              # SonarCloud scanner needs the full history to assign issues properly

definitions:
  caches:
    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
  services:
    docker:
      memory: 7128
  steps:
    - step: &build-test-sonarcloud
        size: 2x
        name: Build, test and analyze on SonarCloud
        caches:
          - sonar
        script:
          - pipe: sonarsource/sonarcloud-scan:1.2.2
    - step: &check-quality-gate-sonarcloud
        size: 2x
        name: Check the Quality Gate on SonarCloud
        script:
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.4

pipelines:
  pull-requests:
    '**':
      - step: *build-test-sonarcloud
        size: 2x
      - step: *check-quality-gate-sonarcloud
        size: 2x

@janos @Nils_Werner

Another question from my colleague is that it is taking more than an hour to scan and every time it is scanning entire codes instead of change codes in pull request. Can you suggest please?

Thanks

I confirm that this is how the software works, today. Even on pull requests, the entire code is analyzed. Then, the scanner filters the result by the detected changed lines in the project, and only stores the relevant files and issues. So the overall analysis duration is not smaller than analyzing the entire project, for most analyzers. (We plan to improve this in the future.)

I let @Nils_Werner chime in about the memory needs and behavior of the analyzer, now that we understand better the composition of your project.