GitLab CI/CD is a tool for software development that uses various CI/CD methodologies. This section explains how you can run Qodana Docker images within GitLab CI/CD pipelines and covers the following cases:
Inspecting specific branches and merge requests
Forwarding inspection reports to Qodana Cloud
Exposing Qodana reports in the GitLab CI/CD user interface
Prepare your project
Make sure that your project repository is accessible by GitLab CI/CD.
In the root directory of your project, save the
.gitlab-ci.yml file. This file will contain the pipeline configuration that will be used by GitLab CI/CD.
This is the basic pipeline configuration.
artifacts configures job artifacts.
Inspect specific branches
only keyword, you can tell Qodana which branches to inspect. To inspect only the
main branch and incoming merge requests, you can use this configuration:
Forward reports to Qodana Cloud
Once the inspection step is complete, inspection reports can be forwarded to Qodana Cloud.
This configuration defines the variables required by Qodana Cloud and referring to the following values:
QODANA_TOKENis the project token of Qodana Cloud
QODANA_REMOTE_URLis the project URL
QODANA_BRANCHis the name of the inspected branch
QODANA_REVISIONis the commit hash
QODANA_JOB_URLis the job URL
Expose Qodana reports
To make a report available in any given merge request, you can use the
expose_as keyword and change the path to the artifacts:
Assuming that you have configured your pipeline in a similar manner, this is what it may look like:
Qodana report affiliated with a pipeline in a merge request
Available actions for a given exposed Qodana artifact
This configuration combines all approaches mentioned in this section.