0

I try to analyze a TypeScript project in Jenkins with SonarQube Scanner plug-in on a Mac OS slave.

Tools:

Problem:

SonarTS plug-in tries to start Node.js, but Node.js is not in the PATH variable, see log:

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.sonar.plugin.typescript.ExternalTypescriptSensor.executeExternalRunner(ExternalTypescriptSensor.java:175)

Research:

I tried to configure the path on Mac with:

I tried to use the already added paths (/usr/bin, /bin, /usr/sbin, /sbin) with:

  • symbolic link

    but it doesn't work, because the paths are write-protected (even for administrator).

I tried to pass the path to the SonarQube Scanner:

I also read about changing path in the calling source:

Cœur
  • 37,241
  • 25
  • 195
  • 267
dur
  • 15,689
  • 25
  • 79
  • 125

2 Answers2

2

If you're using SonarTS 1.2 or later, you could instead try to specify the path to the nodejs executable in the settings using SonarQube UI:

enter image description here

Stas Vilchik
  • 429
  • 2
  • 4
  • That would be a solution, but at the moment we are only using LTS versions (company policy). With the next released LTS version, I will update and use it. – dur Jan 12 '18 at 09:38
  • You can continue using SonarQube 6.7 LTS, but update just the SonarTS plugin. – Stas Vilchik Jan 14 '18 at 18:49
0

Another way is to use Environment Injector Plugin (version 2.1.5):

Summary

EnvInject plugin provides the following features:

  • Removes inherited environment variables by the Jenkins Java process
  • Injects environment variables at node (master/slave) startup
  • Executes a setup script before or/and after a SCM checkout for a run
  • Injects environment variables before or/and after a SCM checkout for a run
  • Injects environment variables as a build step for a run
  • Injects password values for a run
  • Exports environment variables at the end of the build in order to to know the set of environment variables used for each build

So it is possible to add Node.js' path to the PATH variable:

enter image description here

dur
  • 15,689
  • 25
  • 79
  • 125