Analyzing a Typescript project using SonarQube Scanner on a Mac OS slave in Jenkins: A step-by-step guide

My current task involves examining a TypeScript project on Jenkins using the SonarQube Scanner plugin on a Mac OS slave.

Software:

  • Jenkins (version 2.32.1)
  • SonarQube Scanner for Jenkins plug-in (version 2.5)
  • SonarQube Scanner (version 2.8)
  • SSH slave plug-in (version 1.12)
  • SonarQube (version 6.7)
  • SonarTS (version 1.1)
  • Mac OS X (version 10.12.6)

Issue:

The SonarTS plugin attempts to initiate Node.js, but Node.js is not included in the PATH variable, as indicated in the 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)

Exploration:

I attempted to set up the path on my Mac through:

  • environment.plist (from )

    However, this method no longer works.

  • /etc/launchd.conf (from )

    This approach is also obsolete and ineffective.

  • /etc/paths.d/ (from )

    Unfortunately, this too did not resolve the issue (same error message).

I tried utilizing the existing paths (/usr/bin, /bin, /usr/sbin, /sbin) with:

  • a symbolic link

    Regrettably, this method failed due to write-protection of the paths (even for an administrator).

I experimented with passing the path to the SonarQube Scanner:

  • using a JVM option (from )

    However, this did not rectify the situation (same error message).

I also explored adjusting the path in the calling source code:

  • ProcessBuilder#environment() (from )

    While this could be a solution, I refrained from attempting it as I prefer not to modify the SonarQube Scanner source code for maintenance reasons.

  • ProcessStarter#setGlobalSearchPath
    (from )

    Similarly, I chose not to pursue this option to avoid altering the SonarQube Scanner source code (for maintenance purposes).

Answer №1

In the event that you are utilizing SonarTS 1.2 or a more recent version, an alternate approach could be to define the location of the nodejs executable within the settings through the SonarQube user interface:

https://i.sstatic.net/TK1UO.png

Answer №2

If you're looking for an alternative method, consider utilizing the Environment Injector Plugin (version 2.1.5):

Key Features

The EnvInject plugin offers the following functionalities:

  • Eradicates inherited environment variables by the Jenkins Java process
  • Introduces environment variables during node (master/slave) startup
  • Runs a setup script before or after SCM checkout for a run
  • Injects environment variables before or after SCM checkout for a run
  • Adds environment variables as a build step for a run
  • Provides password values for a run
  • Exports environment variables at the conclusion of the build to track the used variables for each build

You can easily include Node.js' path in the PATH variable by using this plugin:

https://i.sstatic.net/eOnd1.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The issue lies in attempting to assign an 'Observable<number[]>' to a parameter expecting an 'Observable<ProjectObject[]>'. This obstacle must be overcome in order to successfully create a mock service

I am currently working on setting up a mock service for unit testing, but I am facing an issue where the observable is not returning the expected fake value. Can someone please assist me in resolving this problem and also explain what might be wrong with m ...

Tips for properly waiting for an AngularFire2 subscription to complete before executing the subsequent lines of code within Angular2

Having an issue with my Angular2 Type Script code. The goal is to access Questions from a Firebase Database by subscribing to a FirebaseListObserver: this.af.list('/questions').subscribe( val => { this.questions = val console.log(th ...

A deep dive into TypeScript: enhancing a type by adding mandatory and optional fields

In this scenario, we encounter a simple case that functions well individually but encounters issues when integrated into a larger structure. The rule is that if scrollToItem is specified, then getRowId becomes mandatory. Otherwise, getRowId remains option ...

Methods for transforming a TypeScript class instance containing getter/setter properties into a JSON format for storage within a MySQL database

I am currently working on a TypeScript class that includes a getter and setter method: export class KitSection { uid: string; order: number; set layout(layout: KitLayout) { this._layout = new KitLayout(layout); } get layout( ...

Guide to showcasing JSON Array in an HTML table with the help of *NgFor

Struggling to showcase the data stored in an array from an external JSON file on an HTML table. Able to view the data through console logs, but unable to display it visually. Still navigating my way through Angular 7 and might be overlooking something cruc ...

Angular: Array in the template re-renders even if its length remains unchanged

Below is the template of a parent component: <ng-container *ngFor="let set of timeSet; index as i"> <time-shift-input *ngIf="enabled" [ngClass]="{ 'mini-times' : miniTimes, 'field field-last&ap ...

Tips for accessing the PR number in a Node.js GitHub Probot listening for the `pull_request` event

I've recently developed a GitHub probot application using nodejs and typescript. Currently, I have set up an event listener for the pull_request event. How can I extract the pr_number from the context object within the probot? The snippet below is fr ...

Encountering a clash in Npm dependencies

I have been involved in a Vue project where I utilized Vue Cli and integrated the Typescript plugin. However, I encountered multiple vulnerabilities that need to be addressed. When I executed npm audit fix, it failed to resolve the dependency conflict: npm ...

Using LINQ with ngFor in Angular 6

Within the component.ts, I extract 15 different lookup list values and assign each one to a list, which is then bound to the corresponding <select> element in the HTML. This process functions correctly. Is there a method to streamline this code for ...

Ways to retrieve particular items/properties from the JSON response string

Is there a way to extract and display only the first 3 items from my JSON data instead of the entire string? Below is the code I am currently using to loop through and display my records: <tr v-for="(list) in myData" v-bind:key="list.ema ...

Creating global variables in NodeJS allows you to access and modify data

Currently, this construct is being utilized to create a global LOG: declare global { let LOG: Logger; } // eslint-disable-next-line @typescript-eslint/no-namespace declare namespace globalThis { let LOG: Logger; } globalThis.LOG = new Logger(); It f ...

The boolean type in TypeScript is throwing an error because it does not have any call

Currently, I am grappling with an issue in my Typescript and React Native project. The error message displayed on the console reads: "This expression is not callable. Type 'Boolean' has no call signatures." My code consists of a simple home page ...

What is the best way to retrieve the output value using the EventEmitter module?

I have an element that sends out a simple string when it is clicked Here is the HTML code for my element: <div (click)="emitSomething($event)"></div> This is the TypeScript code for my element: @Output() someString: EventEmitter<string& ...

Facing problem with implementing NgMoudleFactoryLoader for lazy loading in Angular 8

A situation arose where I needed to lazy load a popups module outside of the regular router lazy-loading. In order to achieve this, I made the following adjustments: angular.json "architect": { "build": { ... "options": { ... "lazyM ...

Angular: How to Disable Checkbox

Within my table, there is a column that consists solely of checkboxes as values. Using a for loop, I have populated all values into the table. What I have accomplished so far is that when a checkbox is enabled, a message saying "hey" appears. However, if m ...

Encountering a "No overload matches this call" error while using React, Typescript, and d3js

Encountered an error in Typescript while using the scaleLinear() function from d3js. Seeking assistance in resolving this issue. The code is in React and utilizes typescript. Below is the source code: import React, { useRef, useState, useEffect } from &apo ...

Leverage a custom server (such as NestJS) within NextJS to dynamically render targeted pages

I am experimenting with using NestJS as a custom server for NextJS, following the instructions in this article. Here is a simplified version of the code: @Controller('/') export class ViewController { @Get('*') async static(@Req() r ...

DateAdapter not found within Angular/Material/Datepicker - Provider not available

I need assistance with: angular / material / datepicker. My test project is running smoothly and consists of the following files: /src/app/app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from ' ...

Encountering an error with Mongoose's .pre('save') method in Typescript

Every time I attempt to use the hash password .pre hook, it refuses to save. userSchema.pre("save", async function (next) { let user = this as UserDocument; if (!user.isModified("password")) return next(); const salt = await bcry ...

Embracing the power of Typescript with Node and Express?

While trying out the TypeScript Node Starter project from Microsoft, I found myself intrigued. Is it really possible to use TypeScript instead of Node on the server? There are a number of server-side tasks where TypeScript excels: - Building a web API ser ...