- Supply a login token directly in the Maven CLI using
-Dsonar.login. - Let Jenkins inject the token via the
withSonarQubeEnvwrapper.
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:
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.