Please can anyone help to resolve, ERROR: CSS rules were not executed. Error when running: 'node -v'

[Pipeline] { (SONARQUBE ANALYSIS)

[Pipeline] tool

[Pipeline] withEnv

[Pipeline] {

[Pipeline] tool

[Pipeline] envVarsForTool

[Pipeline] tool

[Pipeline] envVarsForTool

[Pipeline] withEnv

[Pipeline] {

[Pipeline] withSonarQubeEnv

Injecting SonarQube environment variables using the configuration: sonarqubeserver

[Pipeline] {

[Pipeline] sh

  • /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarqubescanner/bin/sonar-scanner -Dsonar.projectKey=vprofile -Dsonar.projectName=vprofile-repo -Dsonar.projectVersion=1.0 -Dsonar.sources=src/ -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ -Dsonar.junit.reportsPath=target/surefire-reports/ -Dsonar.jacoco.reportsPath=target/jacoco.exec -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml

INFO: Scanner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarqubescanner/conf/sonar-scanner.properties

INFO: Project root configuration file: NONE

INFO: SonarScanner 4.8.0.2856

INFO: Java 1.8.0_362 Private Build (64-bit)

INFO: Linux 5.19.0-1026-aws amd64

INFO: User cache: /var/lib/jenkins/.sonar/cache

INFO: Analyzing on SonarQube server 8.3.0

INFO: Default locale: “en”, source code encoding: “UTF-8” (analysis is platform dependent)

WARN: SonarScanner will require Java 11 to run starting in SonarQube 8.x

INFO: Load global settings

INFO: Load global settings (done) | time=75ms

INFO: Server id: 86E1FA4D-AYhaN7ortYa-K32kH5kD

INFO: User cache: /var/lib/jenkins/.sonar/cache

INFO: Load/download plugins

INFO: Load plugins index

INFO: Load plugins index (done) | time=38ms

INFO: Load/download plugins (done) | time=74ms

INFO: Process project properties

INFO: Process project properties (done) | time=10ms

INFO: Execute project builders

INFO: Execute project builders (done) | time=12ms

INFO: Project key: vprofile

INFO: Base dir: /var/lib/jenkins/workspace/CD-PROJECT3-PIPELINE

INFO: Working dir: /var/lib/jenkins/workspace/CD-PROJECT3-PIPELINE/.scannerwork

INFO: Load project settings for component key: ‘vprofile’

INFO: Load project settings for component key: ‘vprofile’ (done) | time=37ms

INFO: Load quality profiles

INFO: Load quality profiles (done) | time=59ms

INFO: Auto-configuring with CI ‘Jenkins’

INFO: Load active rules

INFO: Load active rules (done) | time=1096ms

INFO: Indexing files…

INFO: Project configuration:

INFO: Load project repositories

INFO: Load project repositories (done) | time=21ms

INFO: 43 files indexed

INFO: 0 files ignored because of scm ignore settings

INFO: Quality profile for css: Sonar way

INFO: Quality profile for java: Sonar way

INFO: Quality profile for jsp: Sonar way

INFO: Quality profile for xml: Sonar way

INFO: ------------- Run sensors on module vprofile-repo

INFO: Load metrics repository

INFO: Load metrics repository (done) | time=41ms

INFO: Sensor JavaSquidSensor [java]

INFO: Configured Java source version (sonar.java.source): none

INFO: JavaClasspath initialization

WARN: Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property.

INFO: JavaClasspath initialization (done) | time=12ms

INFO: JavaTestClasspath initialization

INFO: JavaTestClasspath initialization (done) | time=0ms

INFO: Java Main Files AST scan

INFO: 16 source files to be analyzed

INFO: 16/16 source files have been analyzed

INFO: Java Main Files AST scan (done) | time=2706ms

INFO: Java Test Files AST scan

INFO: 0 source files to be analyzed

INFO: Java Test Files AST scan (done) | time=1ms

INFO: Java Generated Files AST scan

INFO: 0 source files to be analyzed

INFO: Java Generated Files AST scan (done) | time=0ms

INFO: Sensor JavaSquidSensor [java] (done) | time=2929ms

INFO: Sensor SonarCSS Metrics [cssfamily]

INFO: 0/0 source files have been analyzed

INFO: 0/0 source files have been analyzed

INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=66ms

INFO: Sensor SonarCSS Rules [cssfamily]

ERROR: CSS rules were not executed. Error when running: ‘node -v’. Is Node.js available during analysis?

org.sonarsource.nodejs.NodeCommandException: Error when running: ‘node -v’. Is Node.js available during analysis?

at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:83)

at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:196)

at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:169)

at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:144)

at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.initNodeCommand(CssAnalyzerBridgeServer.java:133)

at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServer(CssAnalyzerBridgeServer.java:101)

at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServerLazily(CssAnalyzerBridgeServer.java:153)

at org.sonar.css.plugin.CssRuleSensor.execute(CssRuleSensor.java:99)

at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)

at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)

at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)

at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:386)

at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:382)

at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:351)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)

at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)

at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)

at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)

at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)

at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)

at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)

at com.sun.proxy.$Proxy0.execute(Unknown Source)

at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)

at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)

at org.sonarsource.scanner.cli.Main.execute(Main.java:126)

at org.sonarsource.scanner.cli.Main.execute(Main.java:81)

at org.sonarsource.scanner.cli.Main.main(Main.java:62)

Caused by: java.io.IOException: Cannot run program “node”: error=2, No such file or directory

at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)

at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:175)

at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:79)

… 37 common frames omitted

Caused by: java.io.IOException: error=2, No such file or directory

at java.lang.UNIXProcess.forkAndExec(Native Method)

at java.lang.UNIXProcess.(UNIXProcess.java:247)

at java.lang.ProcessImpl.start(ProcessImpl.java:134)

at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

… 39 common frames omitted

Welcome :slight_smile:

the Sonarqube Scanner needs nodejs for JavaScript, TypeScript and CSS
see JavaScript/TypeScript/CSS

You need to run the Sonarqube scan within a Jenkins nodejs pipeline step, i.e. when using the Sonarqube CLI scanner something like that

nodejs(configId: 'foo', nodeJSInstallationName: 'nodejs-18') {
  
  sh 'node -v'
  sh 'npm -v'
  
  scannerHome = tool 'sonarscanner-4'
  withSonarQubeEnv('foo') {
    sh "${scannerHome}/bin/sonar-scanner"
  }
}

Also you need to update your Sonarqube version, supported are either the LTS = 9.9.1 or latest = 10.1
The upgrade path is 8.3.0 to former LTS 8.9.10 > 9.9.1 > 10.1 (optional)

see

Gilbert