SonarQube Scanner for Jenkins 2.12: waitForQualityGate gives ProxyException

SonarQube Scanner for Jenkins 2.12 seems to introduce a defect whereby configuring sonar server URL (in Configure System) with a trailing slash causes waitForQualityGate to fail with ProxyException.

  • Tested using SonarQube EE 8.2 (and also with 8.3.1).
  • Using SonarQube Scanner for Jenkins 2.12. Previous versions have no error.
  • Jenkins is Jenkins 2.235.5
  • Both SonarQube and Jenkins employ Nginx 1.18.0 configured as reverse proxy.

There are no problems using the plugin in a normal Jenkins maven job. A multibranch pipeline job is also OK with performing the same task… uploading the analysis successfully to the sonarqube server.

The problem occurs with the waitForQualityGate step. The pipeline fails with:

hudson.remoting.ProxyException: net.sf.json.JSONException: Invalid JSON String
	at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:143)
	at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:103)
	at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:84)
	at hudson.plugins.sonar.client.WsClient.getCETask(WsClient.java:53)
	at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.checkTaskCompleted(WaitForQualityGateStep.java:234)
	at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.start(WaitForQualityGateStep.java:171)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:286)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179)
	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
Caused: hudson.remoting.ProxyException: java.lang.IllegalStateException: Unable to parse response from https://sonarserve.foo.bar.com//api/ce/task?id=AXRtQ-Z4bPMU0xbslXRx:
<!doctype html><html lang="en"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" (snip)

Note the URL following “Unable to parse response from”. It has an invalid “//” following the hostname. When I (eventually) spotted that then things were easy to fix.

Sonar URL was configured as: https://sonarserve.foo.bar.com/

Removing the trailing slash resolved the problem and all pipeline builds turned from sad to happy.

However, I do think that this is a defect as the trailing “/” has always worked up to now and it’s not invalid (is it?).

As an aside… I see that plugin 2.12 has not been release in JIRA and that the documentation SonarScanner for Jenkins is also out of date. The latter is also rather sparse. eg " click Add SonarQube , and add the values you’re prompted for." That’s not really that helpful… and the plugin itself is light on in-line help.