Skip to main content
In this guide, we’ll explain how to streamline SonarQube authentication in your Jenkins pipelines. You have two options:
  • Supply a login token directly in the Maven CLI using -Dsonar.login.
  • Let Jenkins inject the token via the withSonarQubeEnv wrapper.
Both methods work—choose one to avoid redundancy and improve security.

Authentication Methods Compared


Original Pipeline (with -Dsonar.login)

Using both withSonarQubeEnv and -Dsonar.login is redundant. Pick one to keep your pipeline clean and secure.

Updated Pipeline (plugin-only authentication)

By removing the -Dsonar.login property, Jenkins uses the credentials defined in Manage Jenkins → Configure System → SonarQube Servers:
When this pipeline runs, the SonarQube stage completes successfully without exposing the token in the Maven command.

Minimal Jenkinsfile Example

For small projects, you can simplify your Jenkinsfile to just the SonarQube stage:
The withSonarQubeEnv step injects the authentication token automatically. No need for -Dsonar.login.

Further Reading

Watch Video

Practice Lab