Sonar-scanner command not found jenkins

Hello everyone!!

Jenkins 2.263.1
SonarQube: 7.9.4
SonarQube Scanner for Jenkins: 2.13
SonarScanner : 4.5.0.2216

Jenkins was installed via the apt package on Ubuntu 18.04.5 LTS.
SonarQube Server was installed on another Ubuntu 20.04.1 LTS VM, with Nginx reverse proxy.

I configured the SonarScanner plugin in Jenkins, but when the pipeline is going to run it says that the sonar-scanner command is not found.

+ /opt/sonar-scanner-4.5.0.2216-linux/sonar-scanner-4.5.0.2216-linux/bin/sonar-scanner --version

/var/lib/jenkins/workspace/Gitea_IFAC_manhanah_master@tmp/durable-f80ff57d/script.sh: 1: /var/lib/jenkins/workspace/Gitea_IFAC_manhanah_master@tmp/durable-f80ff57d/script.sh: /opt/sonar-scanner-4.5.0.2216-linux/sonar-scanner-4.5.0.2216-linux/bin/sonar-scanner: not found

script returned exit code 127

I already tried in Gobal Tools Configuration in SonarQube Scanner to mark to install automatically by Maven, as I provide the path for manual installation, however, the error still persists.

pipeline {
      agent { dockerfile true }
      stage('SonarQube analysis') {

            environment {

                scannerHome = tool 'sonar_scanner'

            }

            steps {

                script{

                    echo '=========== SonarQube analysis ============'

                    withSonarQubeEnv('SonarQube') {

                        sh '${scannerHome}/bin/sonar-scanner --version'

                    }

                }

      }
}

Hi @rennanflima,

Edit:

I can run the latest scanner on Jenkins, without any issues:

Can you double check the path? Or try again using the automatic installer?

Hi,
I’m experience the same issue.

When I login to the Jenkins server and run it manually I don’t get this error.

I tried several configuration in my JenkinsFile.

sonar scanner:
sonarscanner

Jenkins File

Error

any advise?

Can you try ls'ing $scannerHome, to see what’s in there?

withSonarQubeEnv() {
  sh "ls ${scannerHome}"
  sh "echo ${scannerHome}"
}

same result


Am I missing something?

The only think I understand, is that the scanner wasn’t automatically installed. But I have no idea why.

  • Do you see anything in the logs? Perhaps an error when it’s trying to install the scanner? Could it be related to permissions?
  • Did you manage to install other tools on the runner, automatically?

I want install other tools on the runner automatically. But my project has .env file how can I run it.
Sorry my English is a bit poor!!!