I had integrated sonarqube with the jenkins by adding a plugging and changing the configuration. But after i build a project, the build is succeded but not analysis results are added to sonarqube UI. And I cannot click on SonarQube link in the project page after build. but if i run the sonarqube analysis without jenkins i get the results in the web UI.
the sonarqube was also injected to the build:
according to the console output.
Can you please help me to get my integration correct?
Best regads,
Nadis
Install SonarQube Runner and configure it with Jenkins under SonarQube Runner section (Go to Manage Jenkins ->Configure System).
For step by step information on "Configuring Sonar with Jenkins" follow this link.
Related
I have configured sonarqube for one of my projects, but now i want to publish the sonarqube details in my jenkins dashboard. what could be the best possible way to do that?
I'm not sure that there is a straight forward way of getting "all" the data from sonar on to your Jenkins dashboard but can actually get a sonar badge and Quality gate info by using the Sonar plugin for Jenkins.
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/?q=cache:Tbhy8757pK4J:https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/+&cd=1&hl=en&ct=clnk&gl=us
First of all, you need to deploy sonarqube on your local machine, ones it is done, then copy the URL of your sonarqube server, I am assuming, you have deployed sonarqube server on port 9090, once this done, log in to the sonarqube server and then create a project and then generate a token for that project:
Once these above configuration is done, just hit below maven command to generate sonarqube report on the sonarqube server:
mvn sonar:sonar -Dsonar.projectKey=[projectName] -Dsonar.host.url=http://localhost:9090 -Dsonar.login=[tokenId]
Below is the screenshot, this is how your reports on the sonarqube will looks like:
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
I'm looking to install sonarQube on our jenkins server.
The documentation i can find tells me to configure sonar-runner in
Jenkins --> manage Jenkins --> Configure system
however there is no 'sonar runner' option there.
There is a 'sonar' option where i configured my sonar server, and the sonar plugin is installed and up to date.
How do i get the sonar-runner configuration to show up?
(We want the standalone sonar job not the maven on as this is a project without maven.)
In newer versions of Jenkins (like 2.2), the sonarqube runner configuration is under
Manage Jenkins > Global Tool Configuration
Thats the solution :)
Ok. So, if I understand well:
Going into Manage Jenkins' -> 'Manage Plugin' -> tab 'Installed' in the Plugin manager, you can see 'Jenkins Sonar plugin' in the installed plugins.
--> Beware that there is a SonarGraph plugin that is not the proper one. Please verify you have this: http://i.stack.imgur.com/SNZLG.jpg
You say you can install the sonar server part in Jenkins. I understand you refer to this doc http://docs.codehaus.org/display/SONAR/Configuring+SonarQube+Jenkins+Plugin#ConfiguringSonarQubeJenkinsPlugin-AddingSonarQubeServer, and more specifically section 'Adding SonarQube Server' point 2 and 3.
--> Can you confirm that you have this 'Sonar' part under you Jenkins configuration ?
If yes to previous 1 & 2, you should also have the SonarQube Runner part available in Jenkins, as in the previous doc and the post on my blog.
--> Can you confirm this is the part that is lacking ?
Can you try this:
Jenkins -> New Job -> Select 'Build a free-style software project', enter a job Name -> click Ok.
Section Build -> 'Add build Step': can you see the 'Invoke standalone Sonar analysis' menu : http://i.stack.imgur.com/9TmFr.jpg ?
You have SonarQube runner installed and correctly configured: http://docs.codehaus.org/display/SONAR/Installing+and+Configuring+SonarQube+Runnerhttp://docs.codehaus.org/display/SONAR/Installing+and+Configuring+SonarQube+Runner
Do not hesitate to ask for further precision.
I can see both Sonar (just above E-mail Notification section) and Sonar Runner in Jenkins > Configure System section.
I have Jenkins 1.547 and Sonar Plugin 2.1 installed. However, please note that, as per this link, Jenkins 1.491+ and Sonar plugin 2.1 will suffice.
I faced similar issue.
Solution is that you need to run sonar-runner outside jenkins once and then restart jenkins.
To run sonar-runner outside jenkins. Download sonar-runner as mentioned in the steps #
http://docs.sonarqube.org/display/SONAR/Installing
Create a sonar-project.properties file at the root of you code base. below link describes the content of the file. http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Runner
Run sonar-runner.bat from the codebase.
Once the sonar analysis is done, Start Jenkins Jenkins will now show the sonar-runner option in configure page.
I am using Maven as a build tool and Jenkins as a CI tool. Currently I have a Jenkins job configured with a Maven build step.
I started using SonarQube and was wondering what is the advantage of using the Jenkins SonarQube plugin and configuring the SonarQube analysis as a post-build-action over simply adding sonar:sonar to the goals of my existing Maven build step.
Thanks and best regards,
Ronald
You can save a lot of configuration. So, if you use jenkins sonar plugin you can centralize database credentials and sonar credentials but if you make a decision about execute sonar:sonar in each jenkins job you will configure each with the same credentials.
I just found: Why use sonar plugin for Jenkins rather than simply use maven goal "sonar:sonar"?
And to add one reason: Using the Jenkins SonarQube plugins one can specify "Skip if triggered by SCM Changes". This is nice if you trigger your Jenkins job for each commit but only want to do a SonarQube analysis at a scheduled time, e.g. one per night.
And here is a summary of the the points made by "emelendez":
Centralize database credentials and sonar credentials Use jenkins
Use jenkins sonar plugin configuring SonarRunner for non Java projects
I've just changed to maven-sonar-plugin from the Jenkins SonarQube plugin to avoid divergence of information between the pom.xml and sonar-project.properties.
For example, developers elsewhere had bumped the project version number in the pom.xml, but they don't use the Jenkins builds and didn't care about the sonar-project.properties (or probably understand it). By switching to the maven plugin instead, the project version is defined once and referenced in the sonar property set within the pom.
The downside is that I no longer have the SonarQube link from the project's Jenkins page.
I'm not sure where the responsibility might be for adding this link back for projects using maven-sonar-plugin... The link is "owned" by the Jenkins SonarQube Plugin, but this is not being used here. Meanwhile the maven-sonar-plugin component is integrating with maven not Jenkins.
Something would need to observe the build and extract the SonarQube link which is emitted as a [INFO] ANALYSIS SUCCESSFUL, you can browse http://... line in the log.
I want to set up Sonar with Jenkins. But I'm not sure if the Sonar site describes two different ways to do this or if there are two necessary steps:
As far as I understood it, it's two different ways. If this is the case, what is the difference and what are the advantages and disadvantages (between the Sonar itself and Sonar runner)?
If you want to analyse a project with SonarQube and Jenkins, here's what you need:
A SonarQube server up and running
A Jenkins server up and running with the SonarQube Scanner for Jenkins installed and configure to point to your SonarQube server
A job configured to run a SonarQube analysis on your project:
Using the default and standard SonarQube Scanner (suitable for most projects)
Using the SonarQube Scanner for MSBuild (for .NET solutions)
Using a post build action for Maven-based projects
Everything is described more in details on the SonarQube Scanner for Jenkins documentation page.