Forward reports
Edit pageLast modified: 05 March 2025This section explains how you can forward Qodana reports to Qodana Cloud using this software:
note
To provide the correct work of the contributor counting functionality, add the IP address range 54.76.32.8/32 to a list of allowed inbound connections on your side.
Before you start
All configuration examples in this section use a project token generated by Qodana Cloud. This token is required for the paid Qodana linters and optional for use with the Community linters. You can see these sections to learn how to generate the project token in the Qodana Cloud UI:
The project setup section explains how to generate a project token when first working with Qodana Cloud.
The Manage a project section explains how to create a project token within an existing Qodana Cloud organization.
Once you obtain the project token, you can use the QODANA_TOKEN
variable for identifying in a pipeline or workflow.
If you are using a Qodana Cloud instance other than https://qodana.cloud/
, override it by setting the QODANA_ENDPOINT
environment variable.
Docker and Qodana CLI
You can forward Qodana reports to Qodana Cloud using either Docker or Qodana CLI:
Besides QODANA_TOKEN
, you need to provide several additional variables:
Variable name | Description |
---|---|
| Project URL |
| Name of the branch analyzed |
| Commit hash |
| Job URL |
This is the command that uses all these variables:
$docker run \ -v $(pwd):/data/project/ \ -e QODANA_TOKEN="<qodana-cloud-token>" \ -e QODANA_REMOTE_URL="<project-remote-url>" \ -e QODANA_BRANCH="<project-branch-name>" \ -e QODANA_REVISION="<commit-hash>" \ -e QODANA_JOB_URL="<job-url>" \ jetbrains/qodana-<linter>
$qodana scan \ -e QODANA_TOKEN="<qodana-cloud-token>"
Application of these tools implies that the values for all required variables should be provided manually, which is not convenient. Fortunately, you can overcome it using various CI/CD solutions that provide all data required by Qodana Cloud, or contain predefined environment variables that refer to the data required by Qodana Cloud.
Azure Pipelines
In the Azure Pipelines UI, create the
QODANA_TOKEN
secret variable and save the project token as its value.In the Azure pipeline file, add the
QODANA_TOKEN
variable to theenv
section of theQodanaScan
task:- task: QodanaScan@2024 env: QODANA_TOKEN: $(QODANA_TOKEN)
The rest variables and values required by Qodana Cloud are automatically generated by QodanaScan
.
To learn more about Qodana integration with Azure Pipelines, see the Azure Pipelines section of this documentation.
Bitbucket Cloud
Here is the basic configuration snippet for the bitbucket-pipelines.yml
file that lets you run Qodana in Bitbucket Cloud pipelines:
image: atlassian/default-image:4
pipelines:
branches:
main:
- step:
name: Qodana
caches:
- qodana
image: jetbrains/qodana-<linter> # Specify a Qodana linter here. For example, jetbrains/qodana-jvm:latest
script:
- export QODANA_TOKEN=$QODANA_TOKEN # Export the environment variable
- qodana --results-dir=$BITBUCKET_CLONE_DIR/.qodana --report-dir=$BITBUCKET_CLONE_DIR/.qodana/report --cache-dir=~/.qodana/cache
artifacts:
- .qodana/report
definitions:
caches:
qodana: .qodana/cache
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.
To learn more about Qodana integration with Bitbucket Cloud, see the Bitbucket Cloud section of this documentation.
CircleCI
To learn more about Qodana integration with CircleCI, see the CircleCI section of this documentation.
GitHub Actions
On the Settings tab of the GitHub UI, create the
QODANA_TOKEN
encrypted secret and save the project token as its value. If you are using a Qodana Cloud instance other than https://qodana.cloud/, override it by declaring theQODANA_ENDPOINT
environment variable.On the Actions tab of the GitHub UI, set up a new workflow and create the
.github/workflows/code_quality.yml
file.To inspect the
main
andmaster
branches, as well as release branches and the pull requests coming to your repository, save this workflow configuration to the.github/workflows/code_quality.yml
file:name: Qodana on: workflow_dispatch: pull_request: push: branches: # Specify your branches here - main # The 'main' branch - master # The 'master' branch - 'releases/*' # The release branches jobs: qodana: runs-on: ubuntu-latest permissions: contents: write pull-requests: write checks: write steps: - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit fetch-depth: 0 # a full history is required for pull request analysis - name: 'Qodana Scan' uses: JetBrains/qodana-action@v2024.3 env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
To learn more about Qodana integration with GitHub, see the GitHub Actions section of this documentation.
GitLab CI/CD
Create the
$qodana_token
variable, and save the project token as its value.In the root folder of your GitLab-hosted project, create the
.gitlab-ci.yml
file and save this configuration to that file:qodana: image: name: jetbrains/qodana-<linter> entrypoint: [""] variables: QODANA_TOKEN: $qodana_token script: - qodana artifacts: paths: - qodana
In the
image:name
section of this configuration, specify the name of the Qodana Docker image.
To learn more about Qodana integration with GitLab CI/CD, see the GitLab CI/CD section of this documentation.
Jenkins
In the Jenkins UI, create the credentials with the
qodana-token
name as described in the Adding new global credentials section of the Jenkins documentation, and save the project token as the value for these credentials.In the root directory of your project, create the
Jenkinsfile
file and save this configuration to that file:pipeline { environment { QODANA_TOKEN=credentials('qodana-token') } agent { docker { args ''' -v "${WORKSPACE}":/data/project --entrypoint="" ''' image 'jetbrains/qodana-<linter>' } } stages { stage('Qodana') { steps { sh '''qodana''' } } } }
In the
image
section of this script, specify the Qodana Docker image name.
To learn more about Qodana integration with Jenkins, see the Jenkins section of this documentation.
Space Automation
In the JetBrains Space UI, create a secret with the
qodana-token
name, and save the generated project token as its value.In the root directory of your Space-based project, create the
.space.kts
file and save this configuration script to that file:job("Qodana") { container("jetbrains/qodana-<linter>") { env["QODANA_TOKEN"] = Secrets("qodana-token") shellScript { content = """qodana""" } } }
In the
container
section of this script, specify the Qodana Docker image name.
To learn more details about Qodana integration with Space Automation, see the Space Automation section of this documentation.
TeamCity
In the TeamCity UI, open the build step that will run Qodana.
In the Cloud Token field, insert the Qodana Cloud token value.
To learn more about Qodana integration with TeamCity, see the TeamCity section of this documentation.