Scanners unable to find node.js in Jenkins


(Gregg Stum) #1

Community 7.5

scanning an asp.net c# solution with MSBuild scanner 4.5.0.1761 from the command line works fine.

calling it from Jenkins gives these -

‘’’
INFO: Sensor JaCoCo XML Report Importer [jacoco]
ERROR: Failed to get Node.js version. No CSS files will be analyzed.
java.io.IOException: Cannot run program “node”: CreateProcess error=2, The system cannot find the file specified
‘’’

and

‘’’
INFO: Sensor ESLint-based SonarJS [javascript]
INFO: Using default Node.js executable: ‘node’.
ERROR: Failure during analysis, Node.js command to start eslint-bridge server was not built yet.
org.sonarsource.nodejs.NodeCommandException: Error when starting the process: node -v
‘’’

other scanners using node.js, such as SonarCSS, work fine.

I realize that these might be unrelated issues with separate causes.


(G Ann Campbell) #2

Hi,

Could you post the stacktraces for those errors, please?

 
Thx,
Ann


(Gregg Stum) #3

‘’’
INFO: Sensor JaCoCo XML Report Importer [jacoco]
ERROR: Failed to get Node.js version. No CSS files will be analyzed.
java.io.IOException: Cannot run program “node”: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at org.sonar.css.plugin.CssRuleSensor.checkCompatibleNodeVersion(CssRuleSensor.java:138)
at org.sonar.css.plugin.CssRuleSensor.execute(CssRuleSensor.java:94)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:45)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:62)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:164)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:319)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:314)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:312)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:288)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
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:171)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
… 37 common frames omitted

INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=16ms
‘’’

and

‘’’
INFO: Sensor ESLint-based SonarJS [javascript]
INFO: Using default Node.js executable: ‘node’.
ERROR: Failure during analysis, Node.js command to start eslint-bridge server was not built yet.
org.sonarsource.nodejs.NodeCommandException: Error when starting the process: node -v
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:75)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:172)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:145)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:121)
at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServer(EslintBridgeServerImpl.java:114)
at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.execute(EslintBasedRulesSensor.java:81)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:45)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:88)
INFO: Sensor ESLint-based SonarJS [javascript] (done) | time=36228ms
INFO: Sensor C# Properties [csharp]
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:62)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:164)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:319)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:314)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:312)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:288)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
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:171)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: Cannot run program “node”: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:144)
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:71)
… 37 common frames omitted
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
… 39 common frames omitted

INFO: Sensor C# Properties [csharp] (done) | time=32ms
‘’’


(G Ann Campbell) #4

Hi,

Thanks for the stacktraces. I’d like to clarify something. What I take from your OP is this:

where what result
commandline C# project that includes CSS OK
Jenkins non-C# project that includes CSS OK
Jenkins C# project that includes CSS KO

Am I reading it correctly?

 
Thx,
Ann


(Gregg Stum) #5

yes, almost - it’s the first and last, not the middle one.

the two stack traces are from the last case.


(G Ann Campbell) #6

Okay, so CSS analysis on Jenkins always fails?

 
Ann


(Gregg Stum) #7

these scanners only fail in Jenkins; all of them work fine from the command line.

other scanners, such as sonarCSS, are fine in Jenkins.

it seems to be more about node.js rather then css.


(G Ann Campbell) #8

Hi,

Your stacktrace indicates that it’s about SonarCSS trying to find node.js.

That’s why I’m trying to narrow down when you have a problem. To be explicit, if you have a project with only … text and CSS files, does analysis succeed or fail on Jenkins?

 
Ann


(Gregg Stum) #9

project.test.txt (4.6 KB)

project.web.txt (8.5 KB)

attached two files -

  • project.test.txt shows the stack trace of a project containing only a txt file and a css file.

    • here the error appears to come in SonarCSS
  • project.web.txt show the stack trace of the web project in question

    • here the error appears after both JaCoCo XML Report Importer and ESLint-based SonarJS

these are excerpts of the console output when running in Jenkins.
both of these projects work fine when run directly from the command line.


(G Ann Campbell) #10

Hi,

Thanks for the additional logs. After reading your initial problem statement it sounded to me like everything was fine without SonarQube Scanner for MSBuild, but adding that to the mix resulted in not being able to find Node.js. Now it’s clear that CSS analysis never finds Node.js and SQS4MSBuild has nothing to do with it.

So now I can point you to the sonar.css.node property, which you can use to specify the path to Node.js. A few more details here.

 
Ann


(Gregg Stum) #11

ok, that’s fine - I understand that -

how do I set that property in Jenkins?


(G Ann Campbell) #12

Hi,

It’s an analysis property, so you probably want to add it to your command line with -Dsonar.css.node=.

 
Ann


(Gregg Stum) #13

ok, thanks - I managed to get them working now -

  • the first issue was with SonarCSS and resolved by setting sonar.css.node
  • the second issue was with SonarJS and resolved by setting sonar.nodejs.executable
  • the path to node.js had a space, so I needed to re-install to a path without spaces
    • C:\ProgramFiles\nodejs\node.exe instead of C:\Program Files\nodejs\node.exe
  • I set the property values in the Jenkins global config for SonarQube under additional analysis properties

question -

  • is it possible to configure a property value for a path that contains spaces?

(G Ann Campbell) #14

Hi,

Thanks for checking in. I’m glad you got this working.

You probably have to escape them. (I’ve not had to try this).

 
Ann


(Gregg Stum) #15

ok, thanks - any guidance about how to do that would be helpful - I’ve not been able to find any documentation or other information about it. fyi, I’ve tried ", ', ^, and even %20 instead, with no success.


(G Ann Campbell) #16

Hi,

I’d assume a backslash (’’) before the space or maybe enclose the whole path in quotes.

 
Ann


(Gregg Stum) #17

yes, that was my assumption also - you’ll see I tried several characters including double quote.
backslash is not as option since this is windows.
my workaround is to install node.js to a path without spaces.