New code bugs only to display the sonarqube dashboard

Hi,

we have configured new code conditions on the sonarqube, but it will show all new code bugs particular time period, we don’t need it, we need to show the latest commit bugs /to show the sonarqube db,

For example, when the jenkins trigger a new build, that builds bugs that are only displayed on the sonarqube new code, it will not show the yesterday build bugs particular build bugs need to show the soanrqube dashboard

Hello @swarup,

Sorry but

  1. it is a bit complicated to understand what you want, can you explain better
  2. If what you want is to see only the new bugs introduced between 2 successive analysis, technically this would be possible but a very bad practice. That means you would only have to re-analyze the code again to “hide” the bugs of the previous analysis.

Olivier

Hi,

We are planning to if any new bug rise on the sonarqube dashboard, jenkins build get to fail,


for example today I was a trigger 10 jenkins builds, these 10 builds bugs stored in the dashboard, I want the latest build, reporters only,
image

Hello @swarup ,
I understand now.
As I told you before, even if what you want is possible with a convoluted configuration, it’s not a good practice, nor it is a good practice to have a new code period of 1 day. In your example the 121 bugs of today will become 0 tomorrow (meaning that nobody will care to fix them).

My recommendation if you want to get the list of issues between 2 builds is to use the API to extract the new issues, and look at the precise issue timestamp (creation date) to filter those for which you want to do something special.
The API to use is api/issues/search. Something like the below should help you:

curl -X GET -u <SQuserToken>: "https:<SonarQubeURL>/api/issues/search?componentKeys=<yourProjectKey>&createdAfter=YYYY-MM-DD"

See the documentation of api/issues/search for details, there are plenty of more precise options there.

Olivier

Hi,

Thank you for providing the information
We are using Sonarqube 8.9 community version. we are trying to pull request build should fail any new bug rise on the.Sonarqube, once we created bitbucket pullrequest jenkins automatically trigger the build and if any bug rise quality showing red build trigger the failed, we have configured using below script.

#!/bin/bash
sleep 1m
echo “Checking status of SonarQube Project = test-demo11”
sonar_status= `curl -s -u sonartoken: https://sonarqube.com/api/qualitygates/project_status?projectKey=test-demo11 | grep '{' | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["'projectStatus'"]["'status'"];'`
echo “SonarQube status = $sonar_status”
if [ “$sonar_status” = “OK” ]
then
exit 0
elif [ “$sonar_status” = “ERROR” ]
then
echo “ERROR :: Please login sonarqubelink and find the issues [Code Quality and Code Security | SonarQube](https://sonarqube.com/dashboard?id=test-demo11)”
exit 1
fi
#curl -u admin: “[Code Quality and Code Security | SonarQube](https://sonarqube.com/api/issues/search?componentKeys=test-demo&types=BUG&ps=10&facets=severities%2Ctypes&additionalFields=_all)”

but We want

  • Developer will get build failure details in Jenkins console either log messages or Sonarqube link or bitbucket status which contain only new bugs details. Developers should be able to find out new bugs raised because of his commit easily.
  • Maintain the history of PR build failure with details of failures reason as like failed due to new bug or any other.
    Is it possible to use 8.9 version, can we please suggest

This is not possible except for very convoluted scripting, that I will not explain here, because what you’re trying to do is a bad practice.
It’s a bad practice because you should not only focus on the problems introduced between 2 builds, you should focus on the problems introduced since a particular past build of reference (that passes the quality gate).

Hi

We have maintained the last 10day new bugs,

  • is it possible Developer will get build failure details in Jenkins console either log messages or Sonarqube link or bitbucket status which contain only new bugs details. Developers should be able to find out new bugs raised because of his commit easily.?