Skip to Content
sonarqube-cli

βš™οΈ Configuration

Host, token, project and branch, and how flags, environment and files layer.

Settings resolve in layers, each overriding the last:

  1. The config file
  2. Environment variables
  3. Flags

Without a project key from any of those, sonar.projectKey is read from sonar-project.properties in the current directory. There is no default host: set one or the command stops.

SettingEnvironmentFile keyFlag
hostSONARQUBE_HOSThost-H, --host
tokenSONARQUBE_TOKENtoken-t, --token
projectSONARQUBE_PROJECTproject-p, --project
branchSONARQUBE_BRANCHbranch-b, --branch

The host flag is -H because -h always means help.

Config file

The file lives at $XDG_CONFIG_HOME/sonarqube/config.json, or ~/.config/sonarqube/config.json when that variable is unset. Use -c, --config <path> for another file.

sonarqube config set host=https://sonarqube.example.com token=abc project=my-project
sonarqube config show
sonarqube config path

Check what was resolved

sonarqube print-config -p other-project

Prints the final values after all layers, with the token redacted. Useful when a CI job talks to the wrong project.

Upgrading from sonarqube-dash

The package was sonarqube-dash and is now @kud/sonarqube-cli. Both sonarqube and sonarqube-dash binaries are installed. Existing settings keep working: the older environment names and config file are still read, and sonarqube config set writes to the new file. Scripts that passed the host as -h <url> must now use -H <url>.