BetaDeveloper

Exit codes

A reference for the exit codes the SonarQube CLI returns, so you can integrate it into scripts, CI/CD jobs, and Git hooks.

Warning: This product is in Beta stage and we may release breaking changes.

The SonarQube CLI uses exit codes to signal what happened. Use them in scripts and CI/CD to gate pipelines, fail builds, or branch logic.

Code
Meaning

0

Success. The command completed and (where applicable) found nothing to report.

1

Command failure. Network error, authentication failure, server error, or any other unhandled problem.

2

Invalid options. You passed conflicting or unknown flags, or you omitted a required argument.

51

Findings. sonar analyze secrets reports secrets, or sonar analyze / sonar analyze agentic / deprecated sonar verify reports issues on the analyzed change set.

130

Interrupted. You pressed Ctrl+C while the CLI was running.

How to use these in scripts

Treat findings as a failure

Because secrets and analysis findings exit with 51, fail a CI step automatically:

sonar analyze secrets src/
# Step fails if secrets are present (exit 51), passes otherwise.

Distinguish "no findings" from "command broke"

If you want to keep going on findings but stop on real errors, branch on the exit code:

sonar analyze --staged
case $? in
  0)   echo "Clean — no new issues." ;;
  51)  echo "Issues found, but analysis succeeded." ;;
  *)   echo "Analysis failed (exit $?)."; exit 1 ;;
esac

Tolerate Ctrl+C cleanly

In long-running pipelines, treat 130 as a user-initiated cancel and avoid retrying:

Last updated

Was this helpful?