Sonarqube analysis failed on bitbucket pipeline

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube: 9.9.1.69595, SonarScanner 5.0.1.3006, Java 17.0.8 Alpine (64-bit), Linux 5.15.0-1058-aws amd64, Plugin, and any relevant extension)
  • how is SonarQube deployed: Docker
  • what are you trying to achieve
    I’m running sonar scanner in a bitbucket pipeline but it’s failing during execution.
    Below is the script that I’m running to execute sonar scanner:
- pipe: sonarsource/sonarqube-scan:2.0.1
            variables:
                SONAR_HOST_URL: ${SONAR_HOST_URL}
                SONAR_TOKEN: ${SONAR_TOKEN}
                EXTRA_ARGS: '-Dsonar.organization=PRIVATE_VAR -Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions=**/*.test.ts,**/*.test.tsx -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.testExecutionReportPaths=test-report.xml -Dsonar.typescript.tsconfigPaths=tsconfig.sonar.json -Dsonar.eslint.reportPaths=report.json'
  • what have you tried so far to achieve this
    This script used to work a month back. It’s been a month since I last run the pipeline. Today, When I hit the pipeline it failed giving the error which can be seen in log file which says:
ERROR: Error during SonarScanner execution
java.lang.NullPointerException: Cannot read the array length because "<local5>" is null
	at org.sonar.plugins.javascript.external.EslintReportSensor.importReport(EslintReportSensor.java:64)

pipelineLog-{916dfcfb-d6c4-4c9f-9d29-32a266b909f6}.txt (17.7 KB)

Hey there.

It looks like this file isn’t in the expected format.

INFO: Sensor Import of ESLint issues [javascript]
INFO: Importing /opt/atlassian/pipelines/agent/build/report.json

It would be great if you could attach a copy of the report so we can understand more about why it failed to import. Feel free to redact sensitive details, but best to keep the report as in-tact as you can.

Hi there Colin.

Thanks for pointing me in the right direction. Turns out report.json was not being created during execution. After further debugging, I realized that the command to create report.json was failing.

Here is the command that I’m using to generate report:
eslint . --ext ts,tsx -f json > report.json ; exit 0;

This command expects the package eslint-plugin-react-hooks to be installed in the project which was not the case for me. I installed this package and report.json was created successfully.

1 Like