Sonarcloud scan with monorepo(Angular UI) taking more than expected time

Exceeded build time limit of 120 minutes… No errors in logs and it is getting timeout… please help on this issue (Angular UI monorepo)

Hi @Ashwin_S

We can’t help with so little information.
Could you please rewrite your message with all the information asked in the new post template:

Template for a good new topic, formatted with Markdown:

  • ALM used (GitHub, Bitbucket Cloud, Azure DevOps)
  • CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI
  • Scanner command used when applicable (private details masked)
  • Languages of the repository
  • Only if the SonarCloud project is public, the URL
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
  • Steps to reproduce
  • Potential workaround
1 Like

hi @Claire_Villard please find the comments
ALM used ( Bitbucket Cloud
CI system used Bitbucket Cloud
Scanner command used when applicable-

  • npm run test --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox
    - pipe: sonarsource/sonarcloud-scan:1.2.0
    variables:
    SONAR_TOKEN: ${SONAR_TOKEN}
    EXTRA_ARGS: ‘-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="/testing/,**/*.spec.ts" -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info’

Languages of the repository- Angular UI(Node))
SonarCloud project is not public
Error observed- Getting time out before the test finish.

Thanks for the details.
How long does the build take if you remove the sonarcloud-scan pipe?
Has the build succeeded before, and started to hit a timeout recently?

Could you post here, after removal of your project private information, the logs produced by the execution of the sonarcloud-scan pipe?

thanks @Claire_Villard
we had defined app name and it fixed the timeout issue. (

npm run test $App_Name --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox

)

Now it is giving the following error. Please let me know if you have any solutions for it.

INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=62ms
INFO: Sensor JavaScript analysis [javascript]
INFO: Deploying custom rules bundle jar:file:/root/.sonar/cache/1c0d0d6d358b2ff25a27998c60079e2e/sonar-securityjsfrontend-plugin.jar!/js-vulnerabilities-rules-1.0.0.tgz to /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/eslint-bridge-bundle/package/custom-rules17146369475636054303
ERROR: Failed to start server (300s timeout)
org.sonarsource.nodejs.NodeCommandException: Failed to start server (300s timeout)

INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
time=“2021-06-02T11:54:09Z” level=error msg=“error waiting for container: unexpected EOF”

Our SonarJS analyzer relies on a Node.js subprocess to analyze JavaScript code. Here it seems this subprocess is failing to start. Can you share the version of Node.js installed in the container running the analysis?

Also, how many memory has the container, and have you tried increasing it?

Node version is node:12.21.0 and assigned memory is 40969(2x)
this is the node version we are using and the memory.

@Claire_Villard Good day!!!
Any update on the above query…

Hi @Ashwin_S
I promise we didn’t forget you, someone will look at the problem this week.
I just want to clarify that we are doing support here on a best effort basis, and we will do our best to find a solution but we can’t guarantee any deadline for that.

Hi @Ashwin_S,

I noticed that you stated that you assigned memory to be 40969(2x). Can you double check if the memory is assigned according to this guideline: Run Docker commands in Bitbucket Pipelines | Bitbucket Cloud | Atlassian Support ? I suspect that the problem may not be in memory assigned to the step, but to the docker process.

Best,
Marcin

hi,
below is the standards we used which was recommended… please find the configuration below…

####################### Steps defined for build and deployment pipeline #######################
steps:
- step: &Install-Build-Dependencies
image: node:12.21.0
name: Install-Build-Dependenciess
caches:
- node-modules-900
- cypress-900
- cypress-root-900
script:
- npm ci
- npm run postinstall
artifacts:
- target/**

- step: &sonarcloud
    name: Build, test and analyze on SonarCloud
    image: node:12.21.0
    services:
      - docker        
    caches:
      - node
      - sonar
    script:
      - npm ci --quiet
      - pwd
      - export NODE_OPTIONS="--max-old-space-size=8192" 
      - npm run test $App_Name --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox
      - pipe: sonarsource/sonarcloud-scan:1.2.1        
      - pipe: sonarsource/sonarcloud-quality-gate:0.1.4
        variables:
          SONAR_TOKEN: ${SONAR_TOKEN}
          EXTRA_ARGS: '-Dsonar.sources=/apps/$App_Name/src -Dsonar.tests=/apps/$App_Name/src -Dsonar.test.inclusions="**/testing/**,**/*.spec.ts" -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info'
          SONAR_SCANNER_OPTS: -Xmx4096m

Hey @Ashwin_S,

The pipeline setup looks good, but you have to set up additional memory for the docker service in your definitions section. Example:

pipelines:
  default:
    - step: &sonarcloud
...
definitions:
  services:
    docker:
      memory: 4096

Best,
Marcin