Jenkins SonarQube Scanner fails when using Extract *.zip/*.tar.gz installer

SonarQube 8.2-community (docker container running in minikube)
SonarQube Scanner: 4.2.0.1873 (have tried others also)
Jenkins ver. 2.223 (running in container in minikube)

When I use the Extract .zip/.tar.gz installer in Jenkins -> Global Tool Configuration -> SonarQube Scanner -> Add installer and select Extract .zip/.tar.gz the build fails with error message:

/home/jenkins/agent/tools/hudson.plugins.sonar.SonarRunnerInstallation/my-sonar-scanner/bin/sonar-scanner: not found

I have verified the problem using the same sonarqube scanner zip file as the Install from Maven Central uses.

Below is the log output from the two different Jenkins build for each of the installers. When I use the Install from Maven Central it works fine.

Install from Maven Central
Selected SonarQube Scanner 4.2.0.1873

[Pipeline] withEnv
[Pipeline] {
[Pipeline] container
[Pipeline] {
[Pipeline] tool
Unpacking https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/4.2.0.1873/sonar-scanner-cli-4.2.0.1873.zip to /home/jenkins/agent/tools/hudson.plugins.sonar.SonarRunnerInstallation/my-sonar-scanner on jenkins-sonar-23wbf-x5cq8
[Pipeline] withEnv
[Pipeline] {
[Pipeline] unstash
[Pipeline] unstash
[Pipeline] unstash
[Pipeline] unstash
[Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: sonarqube-server
[Pipeline] {
[Pipeline] sh
+ /home/jenkins/agent/tools/hudson.plugins.sonar.SonarRunnerInstallation/my-sonar-scanner/bin/sonar-scanner
INFO: Scanner configuration file: /home/jenkins/agent/tools/hudson.plugins.sonar.SonarRunnerInstallation/my-sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/jenkins/agent/workspace/docap-app_master/sonar-project.properties
INFO: SonarQube Scanner 4.2.0.1873
INFO: Java 1.8.0_212 IcedTea (64-bit)
INFO: Linux 4.19.81 amd64
INFO: User cache: /home/jenkins/.sonar/cache
INFO: SonarQube server 8.2.0
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
WARN: SonarScanner will require Java 11 to run starting in SonarQube 8.x
INFO: Load global settings
INFO: Load global settings (done) | time=406ms
INFO: Server id: A70923A8-AXCmrUk2eJ4rHQTPDl6C

Trying the same sonar-scanner zip file but using the extract .zip/.tar.gz installer.

With Extract .zip/.tar.gz
Download URL for binary archive: https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/4.2.0.1873/sonar-scanner-cli-4.2.0.1873.zip

[Pipeline] withEnv
[Pipeline] {
[Pipeline] container
[Pipeline] {
[Pipeline] tool
Unpacking https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/4.2.0.1873/sonar-scanner-cli-4.2.0.1873.zip to /home/jenkins/agent/tools/hudson.plugins.sonar.SonarRunnerInstallation/my-sonar-scanner on jenkins-sonar-d3rhz-mcrw2
[Pipeline] withEnv
[Pipeline] {
[Pipeline] unstash
[Pipeline] unstash
[Pipeline] unstash
[Pipeline] unstash
[Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: sonarqube-server
[Pipeline] {
[Pipeline] sh
+ /home/jenkins/agent/tools/hudson.plugins.sonar.SonarRunnerInstallation/my-sonar-scanner/bin/sonar-scanner
/home/jenkins/agent/workspace/docap-app_master@tmp/durable-19dff0fd/script.sh: line 1: /home/jenkins/agent/tools/hudson.plugins.sonar.SonarRunnerInstallation/my-sonar-scanner/bin/sonar-scanner: not found
[Pipeline] }
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
[Pipeline] // withSonarQubeEnv

I found the solution. The unpacking is done within a directory with the name of the zip file.

/home/jenkins/agent/tools/hudson.plugins.sonar.SonarRunnerInstallation/my-sonar-scanner/sonar-scanner-4.2.0.1873/bin/sonar-scanner

The solution was to use this in the Jenkinsfile:

    withSonarQubeEnv('sonarqube-server') {
      sh "${scannerHome}/sonar-scanner-4.2.0.1873/bin/sonar-scanner"          
    }
1 Like