Setting up GitLab integration at project level
Setting up GitLab integration features for a project.
Reporting your quality gate status in GitLab for unbound projects
On SonarQube Server projects are bound to their GitLab repository and SonarQube automatically sets up the report of your quality gate status and analysis metrics directly to your GitLab merge requests. For unbound projects, you must set up the quality gate status report manually. The integration of SonarQube Server with GitLab must be properly set up, see Setting up integration at global level.
To report your quality gate status in GitLab for unbound projects:
In the SonarQube Server UI page of your project, select Project Settings > General Settings > DevOps Platform Integration.
Set:
Configuration name: The name of your GitLab instance’s Configuration record set in Setting up integration at global level (Ask your system admin.).
Project ID: Your GitLab project ID (found in GitLab).
Preventing a merge when the quality gate fails
In GitLab, you can block merge requests if it is failing the quality gate. To do this:
In your GitLab repository, go to Your project > Settings > Merge requests.
In the Merge Checks section, select Pipelines must succeed. More information about GitLab’s External status checks can be found in the GitLab Documentation.
Set up the pipeline to fail. If you use GitLab CI/CD, you must configure the SonarScanner to wait for the quality gate result. For more information, see Failing a pipeline job when the quality gate fails for more information.
Reporting vulnerabilities in GitLab
This feature is available starting in Developer Edition and requires GitLab Ultimate and GitLab CI/CD.
Report overview
SonarQube Server can provide feedback about security vulnerabilities inside the GitLab interface itself. The security issues found by SonarQube Server will appear on the Gitlab > Vulnerability report page.
Initially, all issues of type Vulnerability marked Open on SonarQube Server are marked as Needs triage on GitLab. When you update the status of an issue in SonarQube Server, it is also updated in GitLab. Updating the status of an issue in Gitlab does not update it in SonarQube Server.
Setting up the report
The report is set up through your GitLab CI/CD pipeline. The user starting the analysis in the pipeline must have the Browse permission on your project, see Setting project permissions for more details. This user corresponds to the SonarQube Server account used to generate the analysis token in Adding analysis to GitLab CI/CD pipeline.
Proceed as follows:
Add a vulnerability report stage to your
.gitlab-ci.yml
file, as follows:
Last updated
Was this helpful?