title: WaitForQualityGate exit with error on Jenkins slave
body: <p>I'm running a Jenkins instance with 1 master / 1 slave, connected to a Sonarqube instance. I'm using pipeline jobs, and it works fine except on jenkins slave where the "WaitForQualityGate" stage doesn't work. It works fine on master.</p>
  
  <p>My job exit with this error:</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.
  </code></pre>
  
  <p>Even if the stage "withSonarQubeEnv" is called before.</p>
  
  <p>My configuration is:</p>
  
  <ul>
  <li>Jenkins job have a "pipeline script" checking-out my source code + the pipeline script</li>
  <li>Shared libraries are loaded implicitly</li>
  <li>withSonarQubeEnv is called during "testCover" and waitForQualityGate is called during "testQualityGate"</li>
  </ul>
  
  <p>Jenkins job pipeline script:</p>
  
  <pre><code>node(){
      checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'jenkinsfile'], [$class: 'IgnoreNotifyCommit'], [$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'credential', url: 'https://pipeline.git']]]
      checkout changelog: true, scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'src'], [$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'credential', url: 'https://sourcecode.git']]]
      load 'jenkinsfile/Jenkinsfile'
  }()
  </code></pre>
  
  <p>Shared library (testCover):</p>
  
  <pre><code>echo "Testing the coverage of the application"
  withSonarQubeEnv('sonarqube') {
      withCredentials([string(credentialsId: 'sonarqube-token', variable: 'sonarqube_token')]) {
          def scannerCmd = "sonar-scanner -e";
          scannerCmd += " -Dhttps.proxyHost=proxy.com";
          scannerCmd += " -Dhttps.proxyPort=8888";
          scannerCmd += " -Dhttp.proxyHost=proxy.com";
          scannerCmd += " -Dhttp.proxyPort=8888";
          scannerCmd += " -Dsonar.login=${env.sonarqube_token}";
          scannerCmd += " -Dsonar.password=";
          sh "${scannerCmd}"
      }
  }
  </code></pre>
  
  <p>Shared library (testQualityGate):</p>
  
  <pre><code>sleep 10
  timeout(time: 3, unit: 'MINUTES') {
      def qg = waitForQualityGate()
      if (qg.status != 'OK') {
          error "Pipeline aborted due to quality gate failure: ${qg.status}"
      }
  }
  </code></pre>
  
  <p>Pipeline job:</p>
  
  <pre><code>{-&gt;
      node {
          dir('src'){
              stage ('Init') {
                  initLib('node7')
              }
  
              stage ('Build app') {
                  withCredentials([[
                      $class: 'UsernamePasswordMultiBinding',
                      credentialsId: 'npm-server',
                      usernameVariable: 'REG',
                      passwordVariable: 'TOKEN'
                  ]]) {
                      sh "echo '\n//${env.REG}/:_authToken=${env.TOKEN}' &gt;&gt; .npmrc"
                      buildApp()
                  }
              }
  
              stage ('Test / Lint') {
                  testApp()
              }
  
              stage ('Cover / static analysis') {
                  testCover()
              }
  
              stage ('Quality Gate') {
                  testQualityGate()
              }
  
              stage ('Flowdock notification') {
                  notifyFlowdock()
              }
          }
      }
  }
  </code></pre>
  
  <p>EDIT: After investigating deeper, i found out that the problem might come from the 2 calls to <code>node</code> statement (1 in my pipeline script (job), 1 in my pipeline file). Unfortunately, that's not solving my issue =/
  EDIT 2: I checked that the line "Working dir:" and "ANALYSIS SUCCESSFULL" are present in my build log, as Sonar plugin use those lines to find out the URL + the PATH for the ".sonar" folder (where the task-report.txt is), and they are ! So basically, it's working on Master node, but not on Slave, even if they both have the same output =/</p>