Environment variables

A reference for all SonarQube CLI environment variables and instructions to authenticate with SonarQube Server and SonarQube Cloud.

circle-exclamation

Environment variables provide a non-interactive way to configure the SonarQube CLI without running sonar auth login. They are primarily used in CI/CD pipelines and automated environments where interactive authentication is not possible.

circle-info

WSL users: sonar auth login relies on system keychain access, which is not available in WSL. Use the environment variables below to authenticate instead.

Authentication

Set these variables to supply credentials directly. When the CLI finds a valid combination of authentication variables, it uses them immediately and skips any saved connection from sonar auth login.

Variable
Description
Default

SONARQUBE_CLI_TOKEN

Your user token. Required for environment variable authentication.

-

SONARQUBE_CLI_ORG

Your SonarQube Cloud organization key. Use together with SONARQUBE_CLI_TOKEN to authenticate with SonarQube Cloud.

-

SONARQUBE_CLI_SERVER

Your server URL. Use together with SONARQUBE_CLI_TOKEN to authenticate with SonarQube Server. For SonarQube Cloud, use together with SONARQUBE_CLI_ORG and set to https://sonarcloud.io (EU region) or https://sonarqube.us (US region).

https://sonarcloud.io (when SONARQUBE_CLI_ORG is set)

Your SONARQUBE_CLI_TOKEN must be paired with either SONARQUBE_CLI_ORG or SONARQUBE_CLI_SERVER, or both, to connect:

  • Authenticate with SonarQube Cloud, in the EU region: SONARQUBE_CLI_TOKEN + SONARQUBE_CLI_ORG

    • The default value, https://sonarcloud.io, is applied to SONARQUBE_CLI_SERVER.

  • Authenticate with SonarQube Cloud in the US region: SONARQUBE_CLI_TOKEN + SONARQUBE_CLI_ORG + SONARQUBE_CLI_SERVER

    • Users must set SONARQUBE_CLI_SERVER to https://sonarqube.us.

  • Authenticate with SonarQube Server: SONARQUBE_CLI_TOKEN + SONARQUBE_CLI_SERVER

    • User must define the server URL to authenticate.

If only one variable of a required pair is set, the CLI logs a warning and falls back to saved credentials.

circle-info

These variable names (SONARQUBE_CLI_*) are specific to the SonarQube CLI. The SonarQube MCP Server uses different names (SONARQUBE_TOKEN, SONARQUBE_URL, SONARQUBE_ORG).

Examples

Authenticate with SonarQube Cloud:

Authenticate with SonarQube Cloud in the US region:

Authenticate with SonarQube Server:

Last updated

Was this helpful?