How to use my own tsconfig.json in Bitbucket pipeline? error waiting for container: unexpected EOF?

Template for a good new topic, formatted with Markdown:

  • ALM used (, Bitbucket Cloud)
  • CI system used (Bitbucket Cloud
  • Scanner command used when applicable (private details masked)
  • Languages of the repository - Javscript and Typescript

I am trying to use bitbucket pipeline to run sonar scan
Here is the partial build file:

      - step: &build-test-sonarcloud
              name: analyze on SonarCloud
              caches:
              #- ************************** # See https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
              - sonar
              script:
              - echo "analyze on sonarcloud"
              - pipe: sonarsource/sonarcloud-scan:1.1.0
                variables:
                  SONAR_SCANNER_OPTS: "-Xmx2048m"
      - step: &check-quality-gate-sonarcloud
              name: Check the Quality Gate on SonarCloud
              script:
              - pipe: sonarsource/sonarcloud-quality-gate:0.1.3
                variables:
                  DEBUG: "true"

and I got the following error message and the pipeline failed

INFO: 30/30 source files have been analyzed

INFO: Sensor JavaScript analysis [javascript] (done) | time=3406ms

INFO: Sensor TypeScript analysis [javascript]

INFO: Found 1 tsconfig.json file(s): [/opt/atlassian/pipelines/agent/build/tsconfig.json]

INFO: 1029 source files to be analyzed

INFO: Analyzing 1029 files using tsconfig: /opt/atlassian/pipelines/agent/build/tsconfig.json

INFO: Version of TypeScript used during analysis: 3.9.3

WARN: You are using version of TypeScript 3.9.3 which is not officially supported; supported versions >=3.2.1 <3.8.0

ERROR: Failed to analyze file [src/pages/billing/liveBilling/context/InvoicesProvider.tsx]: File '@MASKED/eslint-config/tsconfig.next' not found.
time="2020-07-15T10:26:53Z" level=error msg="error waiting for container: unexpected EOF"

I also tried to run my local machine using sonar-scanner

export SONAR_SCANNER_VERSION=4.2.0.1873
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"

and the scan completes successfully…

Here is my question:

  1. When I run locally, it is using
    INFO: Analyzing 1029 files using tsconfig: /home/ec2-user/sonarcloud/test-project/tsconfig.json and it doesn’t give error not find the tsconfig.next. Could I modify so the bitbucket pipeline uses my tsconfig.json?

  2. Looks like the sonar scanner from bitbucket pipeline sonarsource/sonarcloud-scan:1.1.0 is not the latest version? because I don’t see “TypeScript 3.9.3 which is not officially supported;” when I run locally.

Hi @void

You can add the following property : sonar.typescript.tsconfigPath with the path to your config file

HTH,
Mickaël

1 Like

@void it seems that container on bitbucket pipelne is running out of memory. Can you allocate more memory to the container? You can also configure sonar.javascript.node.maxspace property which sets in MB size of the heap for the analyzer, ie sonar.javascript.node.maxspace=4096 for 4GB.

For TypeScript version, can you check which version of TypeScript (tsc -v) you have when you analyze locally? It should be also printed in the logs of the analysis. Analyzer engine is downloaded during the analysis from SonarCloud so you have the latest analyzer in both cases, I suspect that it’s actually version of TypeScript which differs between local. However, this warning is not so important (it can make some rules behave differently in edge cases, but shouldn’t impact overall analysis).

1 Like

Just for reference, memory issue is similar to the one reported here Memory leak on typescript with multiple projects (3)

1 Like

thank you for your guidance.

thank you. This helps a lot as well. I will give it a try.