With recent developments now branches, both long and short lived, also have QG statuses, not just the master.
Are there plans to support requesting the branch specific quality gate status from the server?
Motivation
The sonar-build-breaker is unmaintained and not compatible with latest releases. ( though a solution is present in a PR)
If the quality gate status could be requested for all kinds of builds on REST, a lightweight solution for to reimplement the QG build breaker might be possible, relying only on the public API, and no dependence on the Sonar Java package structure.
note to me = don’t you ever use real clickable hyperlinks for example urls again,
use preformatted text instead !!
Unfortunately, i can’t edit those older posts anymore to fix this - gets me a lot of
‘Popular Link’ badges though
David, this https://yoursonarhost/web_api/api/project_analyses?internal=true link is simply the link to the builtin web api doc, simply replace yoursonarhost with the name of your instance. It’s also in the footer of your instance, see the ‘Web API’ link.
internal=true means show internal parameters also, there is a checkbox to activate this and also for deprecated stuff.
Whereas the web api api/project_analyses/search has no parameter internal=true.
See the web api docs for parameters and examples and try with browser or a tool as postman.
In your url the internal=true should be deleted and the category QUALITY_GATE is missing.
If you want to dig deeper in the Sonarqube web api you may use the developer tools of your browser
and see what’s going on interacting with Sonarqube web ui.
Do we know if there are any bugs with this? I’m trying to use this to pull a quality gate for a specific branch in my CI/CD pipeline; however, the URL links me to the branch I’m trying to pull, but what the curl is pulling in for JSON doesn’t match my branch and after further inspection, it is pulling the quality gate json for the master branch.
Since i no longer have an instance with 7.9.1 i tried on Sonarqube Enterprise 9.4.0
with https://somesonarhost/api/project_analyses/search?project=org.sonarqube:module1&category=QUALITY_GATE&branch=foobar
Ok, that’s similar to what I see; however the URL that I navigate to doesn’t make the actual JSON that I pull into a variable. Here’s my use case so you understand:
I’m using the api call similar to the below to query SonarQube from a Gitlab pipeline
I’m storing the json results in a variable which I parse through to see if the quality gate passes or fails. When I use that api call, the URL will display the info I expect, but the json that gets stored in the variable is the results from a master branch instead of the branch I specify.
Given my version is so old, I don’t expect anyone to have a solution for me. I was just hoping someone could confirm it was an issue. Ideally, I can convince them to upgrade.
I guess that’s because Sonarqube 7.9.1 still used so called long lived and short lived branches.
Only long lived branches have those events and that might be the reason you get results from the
main branch which is default master and a long lived branch.
i.e. a short lived branch can’t have a sonar.projectVersion
Since Sonarqube 8.x a branch is a branch.
As a customer using the Enterprise edition you need to either use the LTS or the latest version to get support from Sonarsource.
We have been driving with the Enterprise edition since 2016 and switched to using the latest version with the new branching feature in Sonarqube 7.
Beside some glitches in early Sonarqube 8.x version we didn’t have real problems.