2
votes

I followed these instructions to download the SonarQube Scanner plugin for Jenkins. I've configured these jenkins global settings for the SonarQube scanner correctly. The SonarQube server is setup and functioning properly.

https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzinginaJenkinspipeline

But when the build runs, it produces this error: No tool named SonarQube Scanner 2.8 found.

enter image description here

I am using a Jenkins declarative pipeline script for pipeline build.

I am using Jenkins ver. 2.131. I am using "SonarQube Scanner for Jenkins" Plugin version 2.8.1. I believe the Jenkins server is a common linux flavor. I am NOT using any version of Maven, and don't require it to build my projects.

I figured the plugin installed the actual scanner files for me on Jenkins. Do I need to have some version of the scanner command files installed, beyond whatever the plugin provided me? Meaning, is there something other than the plugin that I need to install on by Jenkins server? I would hope the SonarQube plugin would give me everything I would need to run on Jenkins build.

Here's the relavent part of my script:

 stages {
   stage("SonarQube Analysis") {
      agent any
      steps {
        script {
            def scannerHome = tool 'SonarQube Scanner 2.8';
            withSonarQubeEnv("foo") {
              sh "${scannerHome}/bin/sonar-scanner"
            }
        }
      }
    }

Here is a screenshot of the global configuration:

enter image description here

2
can you add a screenshot from the tool config in global configuration, please.StephenKing
@StephenKing Done.Steve Kennedy
Did you also set it up in the tools section?StephenKing
@StephenKing No, I don't know how to do that, and it's not in the instructions for the plugin. ?Steve Kennedy

2 Answers

4
votes

I think you didn't add Scanner in Jenkins Global Tool Configuration. You can do it by doing the following steps:

  • click Manage Jenkins
  • choose Global Tool Configuration
  • scroll to SonarQube Scanner
  • add SonarQube Scanner 2.8

SonarQube Scanner 2.8 configuration

0
votes

May be would be actual for maven's users

stage("SonarQube analysis") {
        steps {
            script {
                def scannerHome = tool 'SonarQube Scanner';
                withSonarQubeEnv('SonarQube Server') {
                    sh 'mvn clean package sonar:sonar'
                }
            }
        }
    }