title: Problem with Connecting Jenkins to SonarQube
body: <p>I have a Jenkins pipeline that periodically pull from gitlab and build different repos, build a multi-component platform, run and test it. Now I installed a sonarqube server on the same machine (Ubuntu 18.04) and I want to connect my Jenkins to sonarqube.</p>
  
  <p>In Jenkins:</p>
  
  <ul>
  <li>I set up the sonarqube scanner at <code>Global Tool Configuration</code> as below:
  <a href="https://i.stack.imgur.com/tcV6k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tcV6k.png" alt="enter image description here"></a></li>
  <li>I generated a token in sonarqube and in Jenkins at <code>configuration</code> I set up the server as below BUT I couldn't find any place to insert the token (and I think this is the problem):
  <a href="https://i.stack.imgur.com/hOBbl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hOBbl.png" alt="enter image description here"></a></li>
  <li>In the jenkins pipeline this is how I added a stage for sonarqube:</li>
  </ul>
  
  <pre><code>stage('SonarQube analysis') {
      steps{
          script {
              scannerHome = tool 'SonarQube';
          }
          withSonarQubeEnv('SonarQube') {
              sh "${scannerHome}/bin/sonar-scanner"
          }
      }
  }
  </code></pre>
  
  <p>But this fails with below logs and <code>ERROR: script returned exit code 127</code>:</p>
  
  <pre><code>[Pipeline] { (SonarQube analysis)
  [Pipeline] script
  [Pipeline] {
  [Pipeline] tool
  Invalid tool ID 
  [Pipeline] }
  [Pipeline] // script
  [Pipeline] withSonarQubeEnv
  Injecting SonarQube environment variables using the configuration: SonarQube
  [Pipeline] {
  [Pipeline] sh
  + /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/bin/sonar-scanner
  /var/lib/jenkins/workspace/wws-full-test@tmp/durable-2c68acd1/script.sh: 1: /var/lib/jenkins/workspace/wws-full-test@tmp/durable-2c68acd1/script.sh: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/bin/sonar-scanner: not found
  [Pipeline] }
  WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
  [Pipeline] // withSonarQubeEnv
  [Pipeline] }
  [Pipeline] // stage
  </code></pre>
  
  <p>And when I check my jenkinstools on the disk sonnar plugin is not there:</p>
  
  <pre><code>$ ls /var/lib/jenkins/tools/
  jenkins.plugins.nodejs.tools.NodeJSInstallation
  </code></pre>
  
  <p>Can someone please let me know how I can connect Jenkins to sonarqube?</p>