title: Jenkins - sonarQube Issue || sonarScanner Plugin
body: <p>We have integrated Jenkins with sonarQube Server using maven auto install default Scanner. Where sonar-scanner is working all fine publishing the results over sonarQube Server, but at waitForQualityGate(), getting below error.</p>
  
  <pre><code>Sonar Scanner Plugin - 2.9
  Jenkins Version - 2.189
  sonarQube Server - 7.2 (Community Edition)
  </code></pre>
  
  <pre><code>
  
  
  </code></pre>
  
  <p>Getting error while validating on sonar results:</p>
  
  <pre><code>[Pipeline] { (SonarQube Quality Gate Results)
  [Pipeline] timeout
  Timeout set to expire in 1 hr 0 min
  [Pipeline] {
  [Pipeline] waitForQualityGate
  Checking status of SonarQube task 'XYZ-123456789' on server 'my_SQ_server'
  [Pipeline] }
  [Pipeline] // timeout
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  java.io.IOException: Failed to authenticate with proxy
      at okhttp3.internal.connection.RealConnection.createTunnel(RealConnection.java:349)
      at okhttp3.internal.connection.RealConnection.connectTunnel(RealConnection.java:197)
      at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:145)
      at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:192)
      at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
      at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
      at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
      at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
      at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
      at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
      at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
      at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
      at okhttp3.RealCall.execute(RealCall.java:69)
      at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:188)
      at org.sonarqube.ws.client.HttpConnector.get(HttpConnector.java:124)
      at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:111)
      at hudson.plugins.sonar.client.HttpClient.getHttp(HttpClient.java:37)
      at hudson.plugins.sonar.client.WsClient.getCETask(WsClient.java:51)
      at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.checkTaskCompleted(WaitForQualityGateStep.java:215)
      at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.start(WaitForQualityGateStep.java:159)
      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 sun.reflect.GeneratedMethodAccessor1726.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:160)
      at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:158)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:162)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:132)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:132)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:132)
      at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
  Caused: java.lang.IllegalStateException: Fail to request https://FQDN/api/ce/task?id=XXXXX
      at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:190)
      at org.sonarqube.ws.client.HttpConnector.get(HttpConnector.java:124)
      at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:111)
      at hudson.plugins.sonar.client.HttpClient.getHttp(HttpClient.java:37)
      at hudson.plugins.sonar.client.WsClient.getCETask(WsClient.java:51)
      at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.checkTaskCompleted(WaitForQualityGateStep.java:215)
      at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.start(WaitForQualityGateStep.java:159)
      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 sun.reflect.GeneratedMethodAccessor1726.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:160)
      at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:158)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:162)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:132)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:132)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:132)
      at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
      at WorkflowScript.run(WorkflowScript:36)
      at ___cps.transform___(Native Method)
      at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:84)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:78)
      at sun.reflect.GeneratedMethodAccessor647.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      at com.cloudbees.groovy.cps.Next.step(Next.java:83)
      at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
      at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
      at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
      at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
      at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
      at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:186)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:370)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:282)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:270)
      at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:66)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
      at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  
  </code></pre>
  
  <p>Validation Code:</p>
  
  <pre><code>stage("SonarQube Quality Gate Results"){
              timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
              def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
              if (qg.status != 'OK') {
                  error "Pipeline Aborted due to Quality Gate failure: ${qg.status}"
              }
              print "Pipeline Quality Gate Status: ${qg.status}, proceeding with BUILD &amp; Deploy Procedures..."   
          }
      }
  </code></pre>
  
  <p>Appreciate help with this.</p>
  
  <p>Here's what we have already tried... Assuming the error is because of some proxy configuration, may be sonar-scanner is using a different proxy than the System. Already tried below:</p>
  
  <ol>
  <li><p>In sonar-project.properties in my VCS
  http.nonProxyHosts=sonarServerFQDN (did not work)
  https.nonProxyHosts=sonarServerFQDN (did not work)
  sonar.ce.javaAdditionalOpts="-Dhttp.nonProxyHosts=sonarServerFQDN" (did not work)</p></li>
  <li><p>Declare an Environment Variable as</p></li>
  </ol>
  
  <p>SONAR_SCANNER_OPTS
  -Dhttp.nonProxyHosts=sonarServerFQDN</p>
  
  <p>(did not work)</p>
  
  <p>Important to note that the Webhook reflects the Last Delivery properly in the Sonar Server Console.</p>
  
  <p>Really appreciate help with this as stuck since a while.</p>