SonarQube "You're not authorized to run analysis" in CI
The scanner authenticated to SonarQube but the token it used is not allowed to run analysis on this project. Either no token was supplied, it is wrong, or its user lacks the "Execute Analysis" permission.
What this error means
The scanner aborts with "You're not authorized to run analysis. Please contact the project administrator." or "Not authorized. Please check the property sonar.token."
ERROR: You're not authorized to run analysis. Please contact the project administrator.Common causes
Missing or invalid SONAR_TOKEN
The SONAR_TOKEN env var was not set from a secret, expired, or was revoked, so the scanner runs unauthenticated or with a dead token.
The token user lacks Execute Analysis permission
The token authenticates but its user does not have the "Execute Analysis" permission on the project, which is required to push analysis results.
How to fix it
Provide a valid token via secret
- Generate a token in SonarQube/SonarCloud under your account security settings.
- Store it as the
SONAR_TOKENrepository secret. - Expose it to the scan step's environment.
- uses: sonarsource/sonarqube-scan-action@v4
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}Grant Execute Analysis to the token user
In Project Settings, Permissions, give the token's user (or a group it belongs to) the "Execute Analysis" permission.
How to prevent it
- Keep
SONAR_TOKENin CI secrets and rotate it before expiry. - Use a dedicated CI user that has Execute Analysis on the project.
- Avoid embedding tokens in committed config files.