Stop Overwriting SonarQube Existing job results - jenkins

I am running a job through Jenkins with the SonarQube Execute Scanner Plugin.
These are all my Analysis Properties
sonar.projectKey=Project1
sonar.projectName=ProProject
sonar.projectVersion=Layer1
sonar.verbose=true
sonar.sources=src
sonar.qualitygate=SonarQube way
sonar.libraries=lib
sonar.tests=Tests
sonar.issuesReport.html.enable=true
sonar.issuesReport.console.enable=true
sonar.includePlugins=views,report,buildbreaker
sonar.analysis.mode=publish
sonar.issuesReport.console.enable=true
sonar.sourceEncoding=UTF-8
When I try to view SonarQube results for my sonar jobs, I see that the result of previous job is being overwritten with the new job.
I am loosing my previous job result

That's the default behavior of this plugin and of SonarQube. If you want to see changes over time in your project's code quality and issues (UI of SonarQube 5.6.2):
go to your SonarQube instance,
click on the name of the project you're interested it,
under the project name, there will be a menu: click on Dashboards -> TimeMachine.
You'll see graphs showing changes in the number of issues, lines of code, test coverage, and so on. In the top right, you should be able to choose a time frame you're interested in.

Related

Link from Jenkins Pipeline page to SonarQube

I've set up a multi-branch pipeline in Jenkins which performs a SonarQube analysis using the withSonarQubeEnv() step and the sonar:sonar Maven goal.
This works fine, and the analysis results do show up in SonarQube.
What I'm missing (compared to the traditional non-pipeline Jenkins integration) is a clickable link on the Jenkins build page which will open the analysis results in SonarQube.
There is a small SonarQube icon next to every build in the left panel, but this icon is not clickable.
Is there any configuration switch that will produce a clickable link, or is this simply a missing feature?
As far as I know Once the job is complete, the plugin will detect that a SonarQube analysis was made during the build and display a badge and a widget on the job page with a link to the SonarQube dashboard as well as quality gate status.
Please refer this and verify your configurations.
If this is happening to you, verify that the test is actually running if not, verify your configuration.
You are probably looking for the SonarQube link on the build job page (for example job/foo/1/). However the link is on the project pate (that is job/foo). There you will find one link on the menu to the left and a SonarQube Quality Gate widget in the bottom center.
Menu
Widget

Sonarqube: reordering published build results

I am publishing build results to Sonarqube, with jenkins.
Each commit on git is triggering a jenkins build.
My problem is that build duration is not deterministic so build #2 can finish before build #1.
Consequently, results are published to Sonar in wrong order and differential view shows wrong results.
For example, if i corrected a unit test in build #2, results of buildĀ #1 will tell me that test is failing again.
Build result version is setted and it should be used to order builds instead of publication date.
Is there any way to do it?
Thank you.
The SonarQube platform is going to process the analysis reports in the order it receives them. It has no way of knowing anything about your Jenkins build number.
Your best bet is to enable the Throttle Concurrent Builds option to make sure that each new job waits its turn. That's the only way to ensure the order you expect.

With a Jenkins multi-configuration build, how do I retrigger one particular configuration?

I have a large and time-consuming multi-configuration build, and once in a while I want to re-trigger only one of the configurations. How can I easily do that? I'd like it to still be easy to see that that all configurations have passed.
There is the Matrix Reloaded plugin
This gives you an interactive way of rerunning combinations
On all Matrix builds that has run while the plugin was installed there
will be a Matrix reloaded link. Click this, and it will take you to a
dialog, where you can check-mark the configurations that should be
build again. Nothing is checked by default, but the check-marks you
set will be cascaded as default settings, if applicable, to any
down-stream jobs triggered by the re-run.

Jenkins Job Current "Log Status"

I've got a job that runs for a long time (for example, it builds few solutions), Is there a way to know the current solution that is beind compiled on runtine?
I mean, the Log is very long, so sometimes is confusing to know what is the current compilation that is running.
I want to know what is the current solution that is being compiled now...
Any plugin or a way to do that?
It would be easier to diagnose problems if you split the job into multiple jobs (each one building a single solution). If you have dependencies between the different builds (i.e. one part of the build cannot happen until another part has completed), you can create a build pipeline, where once one job finishes, it triggers the next job in the pipeline. You can do this using the post-build action Build other projects in the job configuration.
There is also an excellent build pipeline plugin which helps you visualize your build pipeline.
If it is the case that you must have the whole solution built in a single job, then one approach would be to use the Jenkins log parser plugin to display a cut-down version of your build log, which just highlights the key events you are interested in to diagnose such problems.
More details of this plugin can be found at:
https://wiki.jenkins-ci.org/display/JENKINS/Log+Parser+Plugin
I've got two ideas for a possible solution but they needed to be implemented:
1. Adding a prefix for each row in the Log. The prefix could be a string.
for example, if there was a new Project Compilation started then the Log finds the line
----- Rebuild All started: Project: PROJ1 , Configuration: Release x64 ------
Then it adds all the rows after it the prefix "Building PROJ1"
until the log reads the next project:
----- Rebuild All started: Project: PROJ2 , Configuration: Release x64 ------
2. Adding a the current project name that's building to the flashing Job status blue ball.
I mean, finding the current building project from the Log, then adding it next to the current job status (the flickering ball).

Jenkins and Sonar, how to pass down parameter from Jenkins to Ant to create several Sonar projects

I am using Jenkins+Sonar+Ant+java. I am now triggering a Sonar analysis from Jenkins during the night. However, because our full analysis takes so long I would like to define a Jenkins job that analyses only past 1 days of code using the Cutoff plugin (so in every commit, Sonar would analyse the committed code + one day of new code. Actually I would like to analyse only the newly committed code, maybe Cutoff should be 0 then?). For this to work I think I need to setup two different Sonar project names. On Sonar server, I would then have projects "Full analysis" and "New code analysis". The question is, how to define th ename in Jenkins? I think somehow, the Ant task that starts Sonar analysis needs to take the project name from Jenkins, but how is this done?
sonar ant task take project name from properties, you can specify sonar.projectKey and sonar.projectName for different analysis. details
Define the properties sonar.projectKey and sonar.projectName on the ant command line, rather than in a properties file. In Jenkins, you can do this in the Advanced parameters of an Ant builder.

Resources