I’m using SonarQube Version 6.7.3 (build 38370). I’m NOT using the new branch support.
I’m trying to implement automated builds of pull requests, integrating BitBucket and Jenkins with SonarQube. As I’m not using the new branch support, I’m setting “sonar.branch” instead of “sonar.branch.name”. As a result of this, I get a separate project for the pull request. This is ok, as I have automation that deletes the SonarQube project when the pull request branch is deleted (when it is merged).
What isn’t working correctly is that the pull request SonarQube project sometimes gets the wrong quality gate assigned to it on first creation. It’s not acceptable to have to modify it after the fact. If the wrong quality gate is assigned, and the correct thresholds are not observed, the pull request could be marked as mergeable, even though it violates our quality guidelines.
I know the name of the required quality gate. Is there a Sonar property I can set in the build (using the Maven plugin), which will ensure that the resulting project has the correct quality gate?
If there’s no way to include this information on the initial scan, is it possible to call the SonarQube REST api before I run the scan, to ensure the project is created, and set the quality gate for it, and then run the scan?
I can’t find the documentation for the REST api for recent versions.
I noticed https://docs.sonarqube.org/pages/viewpage.action?pageId=2752810#WebService/api/qualitygates-AssociateaProjecttoaQualityGate , but that appears to be obsolete. That page has a link to the new documentation, but I don’t see any description of the REST api there.