SonarQube and Sonar runner installation in Jenkins - sonarqube

I have installed SonarQube-4.3 and Jenkins in my machine. To integrate Sonar with Jenkins installed the SonarQube plugin.
Do I need to install Sonar-runner in my machine in order to trigger a analysis through Jenkins?

You need SonarQube installed and running on same/different machine.
also you require SonarQube plugin in Jenkins which will connect SonarQube for Storing results.
Sonar-runner will be analyzer which will run analysis on your codebase.
You need to install sonar-runner on your local machine and have to specify its path in Jenkins system configuration.
Please find below the screenshots for detail purpose.

Related

SonarQube analysis from maven and Jenkins have different results

I am using SonarQube version 6.7 for running analysis of Maven projects using the command mvn clean verify sonar:sonar from the project directory using command prompt and get the results. The sonar configurations in settings.xml for maven (v3.5.3) are added respectively.
In Jenkins (version 2.161), I have installed SonarQube Scanner for Jenkins (v2.8.1) plugin. The SonarQube Server configuration is configured as below.
In the Jenkins maven project, I have configured the post steps as below.
I have checked the Prepare SonarQube Scanner environment in the Build Environment section and the Build goal is -e clean verify sonar:sonar.
My issue is, when the SonarQube analysis for a maven project is triggered through command prompt using the command mvn clean verify sonar:sonar, I am getting the results as expected. But when the Jenkins job is triggered with the configurations above for the same maven project, the results are different and incorrect. What am I missing?
P.S- In the Post-build Actions, I can see the SonarQube analysis with maven is deprecated.
Thanks in advance.
You use different scanners. First you used SonarScanner for Maven (mvn sonar:sonar). Next you used Basi SonarScanner, which requires manual configuration of all options.
The best option to sole it is always use the same scanner. You have Maven project, so you can enable Prepare SonarQube Scanner environment in Build Environment, and next execute Sonar goal $SONAR_MAVEN_GOAL in Build.

Sonarqube configuration in jenkins for windows

I am trying to integrate Sonarqube in Jenkins for windows.
I have installed Jenkins 2.138.2 and Sonarqube scanner plugin version 2.8.1
Also installed Sonarqube-7.3 and added it to path variable.
Below is my configuration in Jenkins:
Under "Global Tool Configuration", for SonarQube Scanner
installations - I have selected "Install automatically" and choose
"Install from Maven Central".
Under "Configure System", I have specified name and server url for
Sonarqube servers.
For the job, I have selected "Sonarqube analysis with Maven" under
post build action step(shows this is deprecated).
I am getting the below error.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?
SonarQube analysis completed: FAILURE
Build step 'SonarQube analysis with Maven' changed build result to FAILURE
Build step 'SonarQube analysis with Maven' marked build as failure
Is there anything wrong with the configuration.
Edit: Added job configuration screenshots.
Downloading of sonarqube can be done form https://www.sonarqube.org/downloads/ where downloading can be done irrespective to the requirements(here, downloading of Developers Version ver 7.4 is done)
a. It will be downloaded in a zip format and will contain the sonarqube accessing file in various platforms, unzip the folder and extract all the files in your local system.
b. Download the sonarqube scanner, it is helpful cause, it is the only way to start the code analysis, it is the most required or can be said as default launcher to analyse project with SonarQube.
c. To start sonarqube, the start/open the startsonar.bat file.
d. The sonarqube can be runs in default 9000 port.
e. Launch sonarqube locally in the system.

SonarQube compatibility with Jenkins

We are using sonarqube(5.1.2) and jenkins(2.51) to run code analysis. Now we are planning to upgrade sonarqube to version 5.6.4.
Do we also need to upgrade Jenkins ?
No you don't have to.
Sonar is an independent tool, Jenkins is responsible only for running maven/gradle script, that will 'feed' sonar with data. Just make sure you have same credentials for new sonar and it should be fine.
You could consider upgrading Sonar plugin version also.
Just check whether the sonar plugin installed in Jenkins will support the new Sonarqube version else you will have to upgrade the plugin.

How to use SCM Activity plugin in sonar for clearcase

Changed my sonar for scm activity from 3.7 to sonarqube 5.1.1 as it has in built in scm plugin.
Not getting what are the configurations needed to run that and what to pass in
setting->genral setting->scm->sonar.scm.provider
I found this link
http://maven.apache.org/scm/clearcase.html
and created a
URL:- scm:clearcase:baxi_view_4:clinical
Error
org.apache.maven.plugin.MojoExecutionException: SCM provider was set to "scm:clearcase:baxi_view_4:clinical" but no SCM provider found for this key. Supported SCM providers are git,svn
and what other changes or configuration needed in my code or is there anything i have to specify in pom.xml.
I am using jenkins and sonar Integration for CI and reports
You have to install ClearCase plugin for SonarQube. Since there is no official release download a SNAPSHOT from:
https://github.com/SonarCommunity/sonar-scm-clearcase/releases/download/1.0-rc1/sonar-scm-clearcase-plugin-1.0-SNAPSHOT.jar
Plugin documentation is here:
http://docs.sonarqube.org/display/PLUG/ClearCase+Plugin
Make sure to add sonar.scm.provider=clearcase into sonar.properties and re-run SonarQube analysis.
N.B.: We are waiting for positive feedback (on SonarQube Google group) before doing an official release since we do not have Clearcase instance for testing.
Install ClearCase plugin for SonarQube. Download and compile it from:
http://github.com/SonarCommunity/sonar-scm-clearcase
Make sure to add sonar.scm.provider=clearcase into sonar.properties and re-run Sonar analysis.
The machine which runs Jenkins should have ClearCase. And make sure Jenkins can run cleartool command from console.
Thanks #Julien H. - SonarSource Team
For running SonarQube with JRE 7:
From SonarQube page:
The SonarQube Java analyser is able to analyse any kind of java source files whatever is the version of Java they comply to. But SonarQube analysis and SonarQube server require some specific versions of the JVM to be executed.
We can install many JRE versions on our machine. For SonarQube, just set the JRE variable before run it.
Example on Linux
export JRE_1.7=/opt/jre_1.7
export PATH=$JRE_1.7/bin:$PATH
java -version
/opt/sonar/sonarqube-5.1.1/bin/sonar.sh start

How to launch a Grade SonarQube analysis with help of the Jenkins SonarQube plugin

I have installed Sonarqube plugin in Jenkins and configurations are done for SonarQube and sonar-runner in Manage Jenkins->configure System.
I want to trigger analysis for Gradle project. I would like to know the steps to be followed.
The Jenkins SonarQube plugin only allows to easily launch some SonarQube analysis with help of SonarRunner or Maven. If you want to launch a SonarQube analysis with help of the Gradle SonarQube plugin (see the docs) you must manually configure your Jenkins job to execute 'gradle sonarqube'. Simple example for SonarQube with Gradle is provided here.

Resources