SonarQube Plugin for Jenkins does not find SonarQube Scanner executable - jenkins

I am trying to run the SonarQube Scanner within Jenkins as a post-build step. However, I keep getting the error message below:
------------------------------------------------------------------------
SONAR ANALYSIS FAILED
------------------------------------------------------------------------
FATAL: SonarQube Scanner executable was not found for SonarQube
Build step 'Execute SonarQube Scanner' marked build as failure
From similar questions on stackoverflow I read that one should choose "Install automatically" for the SonarQube Scanner, which I have done.
My configurations is as follows:
SonarQube 6.0
Jenkins 1.609.3
SonarQube Plugin 2.4.4
SonarQube Servers
SonarQube Scanner
Build-step

Make sure you are giving path in Global Tool Configuration correctly.
Give the path of folder in which bin folder is exists inside that folder.
Step1 : 1st find where the sonar_scanner bin is available -
root#test1sp117:/opt/sonar_scanner/sonar-scanner-3.0.3.778-linux# ls
bin conf jre lib
Step2 : Give the correct path in Manage Jenkins --> Global Tool Configuration --> SonarQube Scanner

You may want to ensure that both SonarQube and SonarQubeRunner are installed. You would need to configure the SonarQube Runner bin in the Tool Configuration of Jenkins and not the SonarQube server. This fix worked for us.

When you config SonarQube Scanner in Manage Jenkins --> Global Tool Configuration --> SonarQube Scanner, besides select "Install automatically", you also need to add a installer.
See screenshot here:
SonarQube Scanner --> Add Installer

Related

Invalid sonar.source property when SonarQube is on different Server and Jenkins on different Server

Currently I am working on integrating SonarQube with Jenkins using the SonarQube plugin. The problem I am facing is that my Jenkins is running on different Server than SonarQube. So when I am passing sonar.source property like $workspace/src it is not able to find the Jenkins workspace of my repo created by Jenkins due to the different server locations
My project is maven. Below are the details of sonar properties:
sonar.projectKey=$POM_GROUPID:$POM_ARTIFACTID
sonar.projectName=$POM_DISPLAYNAME
sonar.projectVersion=$POM_VERSION
sonar.sources=$WORKSPACE/src
sonar.java.binaries=**/classes/**
P.S - when both Jenkins and SonarQube are on same server SonarQube is able to find the source of workspace
How can I pass the sonar.source of workspace located on Jenkins server so that sonar is able to locate it?
You have to use relative paths. This one is absolute:
sonar.sources=$WORKSPACE/src
This is relative:
sonar.sources=src
But this is not a recommended solution of your problem. You have Maven, so you should use SonarScanner for Maven, steps:
remove the configuration which you added
configure sources (two options):
add a new property to your pom.xml: <sonar.sources>pom.xml,src</sonar.sources>
add parameter to mvn command: -Dsonar.sources=pom.xml,src
execute SonarScanner sonar:sonar
Example:
mvn package sonar:sonar -Dsonar.sources=pom.xml,src

Project is empty at sonarqube

Why after successful analysis at jenkin, my project is empty at sonarqube.
Console output at jenkin:-
Sonarqube scanner details:-
Sonarqube/localhost details:-
Install Swift plugin in sonar. By default sonar check only java code. Then run jenkins job again.

Do Jenkins and SonarQube need to be on the same machine?

I am trying to run a SonarQube scan from Jenkins job. I have the SonarQube Scanner for Jenkins plugin installed v2.6.1 running on local Jenkins (for dev only);
I have seen conflicting reports on whether or not you can run SonarQube on a different server then Jenkins. It wouldn't make sense if you could not do that... if you can, instructions on how to accomplish it would be great. Simply putting in the URL to the SQ server where Jenkins expects a directory to Sonar Runner locally, does not work.
Jenkins and SonarQube do not have to be on the same machine.
The SonarQube plugin in Jenkins will run one of these three scanners:
SonarQube Scanner
SonarQube Scanner for Maven
SonarQube Scanner for MsBuild
Depending on which scanner you use, it works a bit differently:
For the SonarQube Scanner, pass -Dsonar.host.url=http://your.host:1234 as additional arguments. (or add it to your sonar.properties file)
For the SonarQube Scanner for Maven, add -Dsonar.host.url=http://your.host:1234 to your maven build step.
For the SonarQube Scanner for MsBuild, add /d:sonar.host.url=http://your.host:1234 to your MsBuild.exe call.

SonarQube runner made error on Jenkins

I use Jenkins and plugin SonarQube and Sonar runner.
For SonarQube Runner installation in Jenkins, it made Warning like this.
/home/abc/sonnar-runner-2.4 is not a directory on the Jenkins master (but perhaps it exists on some slaves)
of course I made /home/abc/ directory on the Jenkins Server.
so.. i ignore the warning and try to build tho..
it made error like this.
SONAR ANALYSIS FAILED
FATAL: SonarQube runner executable was not found for sonar-runner-2.4
Build step 'Invoke Standalone SonarQube Analysis' marked build as failure
Finished: FAILURE
i cant figure out this problem
is there anyone know how to solve this?
When you config SonarQube Scanner in Manage Jenkins --> Global Tool Configuration --> SonarQube Scanner, besides select "Install automatically", you also need to add a installer.
See screenshot here:
SonarQube Scanner --> Add Installer

Sonar Analysis using Jenkins can't find executable

I'm trying to trigger a sonar analysis of an android application through Jenkins and the Sonar Runner plugin. I've added a "Invoke Standalone Sonar Analysis" build step to my job that builds the code using Ant. When it gets to the Sonar Analysis step it fails and outputs the following:
------------------------------------------------------------------------
SONAR ANALYSIS FAILED
------------------------------------------------------------------------
FATAL: Sonar runner executable was not found for Sonar Runner 2.2.2
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
The jenkins agent is a remote linux server where I have installed the sonar-runner in /opt/ and have updated appropriate SONAR_RUNNER_HOME and PATH variables.
Have I installed the runner correctly? I've looked at the documentation and other similar installation related questions but have not found what my problem could be.
Make sure to set the path of the runner correctly in Jenkins. It's the path without */bin in the end. That's a little tricky.
In the Manage Jenkins section, Configure... did you set the Sonar Runner Installations correctly? Check box Install automatically and install automatically the version from Codehaus.
Install Sonar Runner in the same server where Jenkins has been installed.

Resources