sonarqube-cli

🧰 Commands

Every command, its flags, and the options shared by all of them.

Shared flags

Every command that talks to SonarQube accepts these.

FlagMeaning
-H, --host <url>Server URL (-h is always help)
-t, --token <token>Auth token
-p, --project <key>Project key
-b, --branch <name>Branch
-c, --config <path>Config file to use instead of the default
-j, --jsonJSON output

Commands that show a single object (issue, hotspot, rule, duplications) also take --url to print its web URL and --open to open it in the browser.

Issues

sonarqube issues --new-code --severities CRITICAL,MAJOR -l 25
sonarqube issues:summary
sonarqube issue <key> --open
FlagValues
--severitiesBLOCKER,CRITICAL,MAJOR,MINOR,INFO
--typesBUG,VULNERABILITY,CODE_SMELL,SECURITY_HOTSPOT
--statusesOPEN,CONFIRMED,REOPENED,RESOLVED,CLOSED (default: unresolved)
--new-codeOnly issues in the new-code period
-l, --limitMax issues (default 10)
-iOpen the dashboard instead of printing

Each issue shows its author (the part before @) and creation date as YYYY-MM-DD. issues:summary prints counts by severity, type and status; --facets <list> changes the facets.

Hotspots

sonarqube hotspots --status TO_REVIEW --severity HIGH
sonarqube hotspot <key>

hotspots takes --status (TO_REVIEW or REVIEWED), --severity (LOW, MEDIUM, HIGH) and -l, --limit (default 50).

Rules

sonarqube rules -q "cognitive complexity" --languages ts
sonarqube rule <key>

rules takes -q, --query, --languages, --tags, --repository, --severities and -l, --limit (default 50).

Measures and files

CommandPurpose
measures -C <key>Measures for a component; -m picks metrics
measures:history -C <key>History with sparklines; --from and --to as YYYY-MM-DD
component-tree -C <key>Files under a component; -q qualifiers, --strategy leaves|children
duplications -f <file>Duplicated blocks in one file
quality-profilesQuality profiles; --language filters

-m defaults to coverage,bugs,vulnerabilities,code_smells.

Config helpers

CommandPurpose
print-configThe resolved configuration after every layer, token redacted
config set k=v…Write host, token, project or branch to the file
config get <key>Print one stored value (the token prints as ***)
config showThe stored file, token redacted
config pathWhere the file lives