Jenkins and node

Hi

I’m running Jenkins on Windows and currently building a C# project the project builds fine and the scanning occurs. But I’m noting that it complains about not being able to find node.

ERROR: 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?

Node is installed on the machine and in the system path at C:\nodejs. I have been looking at this thread

Using that thread I updated my Jenkins command line to read:

image

But I’m getting: Unrecognized command line argument: -Dsonar.css.node=C:\nodejs in the logs. I’m not too bothered about css analysis, mainly it’s for JavaScript, so I also tried

image

But also getting: Unrecognized command line argument: -Dsonar.nodejs.executable=C:\nodejs.

So what am I doing wrong here? :slight_smile:

Edit
I have also tried: /d:sonar.nodejs.executable="C:\nodejs" but get the same result

Hi,

I think this input is designed to add the /d: for you. Have you tried just setting sonar.nodejs...?

 
Ann

Hi

I tried that and got the following:

Getting version 'C9918' to 'C:\Jenkins\workspace\INFP'...

Finished getting version 'C9918'. Retrieved 3457 resources. [INFP] $ C:\Jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\SonarMSB46\SonarScanner.MSBuild.exe begin /k:INFP /n:INFP /v: /d:sonar.host.url=[http://localhost:9000](http://localhost:9000/) ******** sonar.nodejs.executable=C:\nodejs 
SonarScanner for MSBuild 4.6.2 
Using the .NET Framework version of the Scanner for MSBuild Pre-processing started. Preparing working directories... 
11:48:17.949 11:48:17.949 Unrecognized command line argument: sonar.nodejs.executable=C:\nodejs 
11:48:17.949 Expecting at least the following command line argument: - SonarQube project key

Okay! Clearly I’m wrong then. :slight_smile: Hopefully someone who knows the domain better will chime in.

 
Ann

Can you confirm that you get the same error message please? I think specifying a property in that form should be accepted by the Scanner for MSBuild, even if it isn’t handled by a plugin.

Hi @duncanp

I just ran and got the following.

INFO: Using Node.js executable C:\nodejs from property sonar.nodejs.executable.
INFO: Sensor ESLint-based SonarJS [javascript] (done) | time=4313ms
INFO: Sensor C# Properties [csharp]
ERROR: Error when running: ‘C:\nodejs -v’. Is Node.js available during analysis?
org.sonarsource.nodejs.NodeCommandException: Error when running: ‘C:\nodejs -v’. Is Node.js available during analysis?
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:77)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:171)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:144)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:120)
at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.initNodeCommand(EslintBridgeServerImpl.java:129)

hello @jonny7,

property should point to the executable file, not just directory where nodejs is installed. In your case it should be probably c:\nodejs\node.exe

Yes, I just tried that and was going to reply.

Thanks guys :slight_smile:

2 posts were split to a new topic: Configure nodejs.executable on SQ level