title: Sonar Qube Quality Gates plugin in Jenkins pipline
body: <p>i've installed and configure a SonanarQube Qualuity Gates plugin and successfully configured it in a non-pipline job. But when u try to configure it in pipline i face an different errors, when i try to make pipline like this:</p>
  
  <pre><code>stage ("SonarQube analysis") {
   dir('source') {
              def scannerHome = tool 'sonscanner';
               withSonarQubeEnv('sonar'){
                 timeout(time: 1, unit: 'HOURS');
                   withSonarQubeEnv('sonar'){
                        def qg = waitForQualityGate()
               if (qg.status != 'OK') {
                error "Pipeline aborted due to quality gate failure: ${qg.status}"
        }
            } 
               } 
                  } 
                    }         
  </code></pre>
  
  <p>i see this: </p>
  
  <pre><code>java.lang.IllegalStateException: There is no body to invoke
  at org.jenkinsci.plugins.workflow.cps.CpsStepContext.newBodyInvoker(CpsStepContext.java:283)
  at org.jenkinsci.plugins.workflow.cps.CpsStepContext.newBodyInvoker(CpsStepContext.java:95)
  at org.jenkinsci.plugins.workflow.steps.TimeoutStepExecution.start(TimeoutStepExecution.java:46)
  </code></pre>
  
  <p>When as separate step after SonarQube analytics :</p>
  
  <pre><code>stage("Quality Gate"){
          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}"
  
            } else {
  
                  echo 'Quality Gate PASSED'
  
              }
  
          }
  
      }
  </code></pre>
  
  <p>Than </p>
  
  <pre><code>java.lang.IllegalStateException: Unable to get SonarQube task id and/or server name. Please use the 'withSonarQubeEnv' wrapper to run your analysis.
  at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.processStepParameters(WaitForQualityGateStep.java:125)
  at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.start(WaitForQualityGateStep.java:107)
  at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:224)
  at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:150)
  at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
  </code></pre>
  
  <p>And when pipline :</p>
  
  <pre><code>     stage ("SonarQube analysis") {
  
   dir('source') {
  
              def scannerHome = tool 'sonscanner';
  
               withSonarQubeEnv('sonar'){
  
              sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=android -Dsonar.sources='${WORKSPACE}'/source -Dsonar.language=java -Dsonar.projectBaseDir='${WORKSPACE}'/source -Dsonar.java.binaries='${WORKSPACE}'/source/app/build/intermediates/classes/debug -Dsonar.junit.reportsPath='${WORKSPACE}'/sourceapp/build/test-results/testDebugUnitTest"
  
    }    
  
       }              
  
         }
  
  
  
    stage("Quality Gate"){
  
          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}"
  
              } else {
  
                  echo 'Quality Gate PASSED'
  
              }
  
          }
  
      }
  </code></pre>
  
  <p>This: </p>
  
  <pre><code>Caused: java.lang.IllegalStateException: Unable to parse response from https://sonar//api/ce/task?id=AWCYPE3v1VuUrqmUzLyR:
  </code></pre>