Error during SonarScanner execution Failed to parse JSON in SONARQUBE_SCANNER_PARAMS environment variable

I am using SonarQube scanner 2.6.0 for my Node.JS application. I run the following analayse.js code with SONAR_SCANNER_OPTS="-Djavax.net.ssl.trustStore=/tmp/sonarqube/cacerts -Djavax.net.ssl.trustStorePassword=changeit"

const scanner = require("sonarqube-scanner");
scanner(
  {
    serverUrl: "http://url:9000",
	token: "whatever",
    options: {
		"sonar.projectKey": "nsbportalwebservices",
		"sonar.projectVersion": "1.0.0",
		"sonar.sourceEncoding": "UTF-8",
		"sonar.scm.disabled": "true",
		"sonar.qualitygate": "NodesJSQualityGate",
		"sonar.sources": "BusinessLogic, routes, bin, app.js, package-json.lock",
		"sonar.tests": "tests",
		"sonar.dependencyCheck.reportPath": "dependency-check-report.json",
		"sonar.dependencyCheck.htmlReportPath": "dependency-check-report.html",
		"sonar.javascript.jstest.reportsPath": "test_reports",
		"sonar.javascript.lcov.reportPaths": "coverage/lcov.info",
		"sonar.testExecutionReportPaths": "test_reports/sonarqube/test_results.xml",
		"sonar.dependencyCheck.severity.blocker": 9.0,
		"sonar.dependencyCheck.severity.critical": 7.0,
		"sonar.dependencyCheck.severity.major": 4.0,
		"sonar.dependencyCheck.severity.minor": 0.0,
		"sonar.dependencyCheck.summarize": true
    }
  },
  () => process.exit()
);

and the following exception is thrown:

ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Failed to parse JSON in SONARQUBE_SCANNER_PARAMS environment variable
	at org.sonarsource.scanner.api.Utils.loadEnvironmentProperties(Utils.java:65)
	at org.sonarsource.scanner.cli.Conf.loadEnvironmentProperties(Conf.java:88)
	at org.sonarsource.scanner.cli.Conf.loadGlobalProperties(Conf.java:95)
	at org.sonarsource.scanner.cli.Conf.properties(Conf.java:60)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:69)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.UnsupportedOperationException: Not a string: 9
	at org.sonarsource.scanner.api.internal.shaded.minimaljson.JsonValue.asString(JsonValue.java:384)
	at org.sonarsource.scanner.api.Utils.loadEnvironmentProperties(Utils.java:61)
	... 5 more

Any advice and insight is appreciated.

Hi,

I’m guessing that if you look at the response it’s trying to parse you’ll find not a JSON payload by a server error page. We see this kind of thing when the SonarQube URL is only slightly misconfigured.

 
HTH,
Ann