Sonarcloud analysis failing to scan java project with node error

  • ALM used: Bitbucket
  • CI system used: Bitbucket Cloud
  • Scanner command used when applicable (private details masked)
mvn -B sonar:sonar -Dsonar.token=$SONAR_TOKEN -P allModules -f brm-parent/pom.xml
  • Languages of the repository: Java

  • Error observed:

I have a maven java project, which is scanned via sonarcloud on bitbucket cloud pipeline.
I have been getting errors while scanning, due to a node version not being found, however as this is a java maven project, i don’t need the js/css/html scanning to take place. I have tried disabling by adding this to the pom.xml

        <sonar.exclusions>
            **/*.js,
            **/*.jsx,
            **/*.cjs,
            **/*.mjs,
            **/*.vue,
            **/*.ts,
            **/*.tsx,
            **/*.cts,
            **/*.mts,
            **/*.html,
            **/*.htm,
            **/*.yaml
        </sonar.exclusions>

But it still tries to scan the js/css/html files. It errors here, when trying to run JS in HTML scan

[INFO] 16:52:05.878 Sensor JavaScript inside HTML analysis [javascript]
[INFO] 16:52:07.657 Detected os: Linux arch: amd64 alpine: false. Platform: LINUX_X64
[ERROR] 16:52:10.662 /root/.sonar/js/node-runtime/node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /root/.sonar/js/node-runtime/node)
[ERROR] 16:52:10.662 /root/.sonar/js/node-runtime/node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /root/.sonar/js/node-runtime/node)
[WARNING] 16:52:10.664 Embedded Node.js failed to deploy. Will fallback to host Node.js.
org.sonar.plugins.javascript.nodejs.NodeCommandException: Failed to determine the version of Node.js, exit value 1. Executed: '/root/.sonar/js/node-runtime/node -v'

How do i make sure the exclusion is working, to get sonar to ignore the js/html/css and not require node.js for scanning my maven project?

Hey there.

First thing you can check is in your analysis logs.

[INFO] Project configuration:
[INFO] Excluded sources: **/*.js, **/*.jsx, **/*.cjs, **/*.mjs, **/*.vue, **/*.ts, **/*.tsx, **/*.cts, **/*.mts, **/*.html, **/*.htm, **/*.yaml

Do you see this in your analysis logs?

Yea this line shows in the analysis log

[INFO] 08:30:19.910 Project configuration:
[INFO] 08:30:19.910   Excluded sources: **/build-wrapper-dump.json, **/rent/bike/obw3/client/**/*.java, **/brm-legacy/src/main/webapp/**, **/*.js, **/*.jsx, **/*.cjs, **/*.mjs, **/*.vue, **/*.ts, **/*.tsx, **/*.cts, **/*.mts, **/*.html, **/*.htm, **/*.yaml

But then still seems to run the Javascript inside HTML analysis.

I have since fixed this by creating a docker image with maven and nodejs installed, which seems to fix the issue now