Environment variables
A reference for all SonarQube CLI environment variables and instructions to authenticate with SonarQube Server and SonarQube Cloud.
This product is in Beta stage and breaking changes may be released. The documentation here matches the release version listed in the table of contents.
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.
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.
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_ORGThe default value,
https://sonarcloud.io, is applied toSONARQUBE_CLI_SERVER.
Authenticate with SonarQube Cloud in the US region:
SONARQUBE_CLI_TOKEN+SONARQUBE_CLI_ORG+SONARQUBE_CLI_SERVERUsers must set
SONARQUBE_CLI_SERVERtohttps://sonarqube.us.
Authenticate with SonarQube Server:
SONARQUBE_CLI_TOKEN+SONARQUBE_CLI_SERVERUser 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.
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:
Related pages
The list of SonarQube CLI Commands
The SonarQube CLI Quickstart guide
Last updated
Was this helpful?

