Nodejs "sonarqube-scanner" requires needs a download from https://binaries.sonarsource.com

I am trying to run Sonar scans on my nodejs application.

I have installed the sonarqube-scanner package and am trying to run it like example states:

const scanner = require('sonarqube-scanner');

scanner(
  {
    serverUrl : 'https://sonarqube.mycompany.com',
    token : "019d1e2e04eefdcd0caee1468f39a45e69d33d3f",
    options: {
      'sonar.projectName': 'My App',
      'sonar.projectDescription': 'Description for "My App" project...',
      'sonar.sources': 'src',
      'sonar.tests': 'test'
    }
  },
  () => process.exit()
)

The nodejs package “sonarqube-scanner” works great when I run it from my local windows 10 machine.

But then when I run it from my azure devops build agent, I get this problem:

Starting: Run sonarqube scan
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.178.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
node sonarqube/sonar.js
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "E:\Dev\Agents\_work\_temp\b1d0f604-eeb6-4d68-b6b4-a885c070eb0f.cmd""
[15:05:07] Starting analysis...
[15:05:07] Executable parameters built:
[15:05:07] {
  targetOS: 'windows',
  installFolder: 'C:\\Users\\mybuildaccount\\.sonar\\native-sonar-scanner',
  platformExecutable: 'C:\\Users\\mybuildaccount\\.sonar\\native-sonar-scanner\\sonar-scanner-4.7.0.2747-windows\\bin\\sonar-scanner.bat',
  fileName: 'sonar-scanner-cli-4.7.0.2747-windows.zip',
  downloadUrl: 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-windows.zip'
}
[15:05:07] Trying to find a local install of the SonarScanner: C:\Users\mybuildaccount\.sonar\native-sonar-scanner\sonar-scanner-4.7.0.2747-windows\bin\sonar-scanner.bat
The system cannot find the path specified.
[15:05:07] Proceed with download of the platform binaries for SonarScanner...
[15:05:07] Creating C:\Users\mybuildaccount\.sonar\native-sonar-scanner
[15:05:19] error in downloader
[15:05:19] Error: getaddrinfo ENOTFOUND binaries.sonarsource.com
[15:05:19] Retrieving info from "package.json" file
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'binaries.sonarsource.com'
}
[15:05:19] ERROR: impossible to download and extract binary: getaddrinfo ENOTFOUND binaries.sonarsource.com
[15:05:19]        SonarScanner binaries probably don't exist for your OS (windows).
[15:05:19]        In such situation, the best solution is to install the standard SonarScanner (requires a JVM).
[15:05:19]        Check it out at https://redirect.sonarsource.com/doc/install-configure-scanner.html
Finishing: Run sonarqube scan

Is there some better way to run this using Java/Maven so that I don’t have this problem? This same node runs java sonarqube scans all the time.

-Nicholas

dropped it in
%USERHOME%.sonar\native-sonar-scanner
manually now it works.

1 Like