Bitbucket Cloud
Bitbucket Cloud is a tool that gives teams one place to plan, collaborate, test, and deploy their code. This section explains how you can run Qodana Docker images within Bitbucket Cloud pipelines and covers application of the quality gate and baseline features.
Prepare your project
Using the Bitbucket Cloud UI, create a repository.
In the Bitbucket Cloud repository, create a pipeline. This will generate the
bitbucket-pipelines.yml
file for storing a pipeline configuration.
Basic configuration
Here is the basic configuration snippet for the bitbucket-pipelines.yml
file that lets you run Qodana in Bitbucket Cloud pipelines:
Here, the branches
block specifies which branches to inspect.
The image
block specifies the Qodana linter that will be invoked in the pipeline.
The script
block contains the - export QODANA_TOKEN=$QODANA_TOKEN
line that specifies the project token required by Qodana Cloud and saved as the $QODANA_TOKEN
variable. The - qodana ...
line in this block tells Bitbucket which directories to use while running the pipeline, and it can also contain Qodana options.
This configuration will be used as a basis for all examples in this section.
Quality gate
Using the --fail-threshold
option, you can configure the limit of problems accepted in your project:
Baseline
Use the --baseline <path/to/qodana.sarif.json>
option to specify the path to the SARIF-formatted file used as a baseline:
Generate Code Insights reports
Starting from version 2024.1 of Qodana, using the pull request UI of Bitbucket Cloud you can view specific lines of code that contain problems along with their description and recommendations for improvement. By default, Qodana generates Code Insights reports, forwards them using the Bitbucket Code Insights API, and does not require any configuration.