I am trying to anaylse my maven project through jenkins pipeline.
I have configured my SonarQube server instance in global settings of Jenkins with authorized token and server URL.
Following is the groovy script in my jenkinsfile :
stage('SonarQube analysis') {
tools {
jdk "jdk-8u152"
}
steps {
withSonarQubeEnv('My Sonar') {
sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar -Dsonar.login=XXXXXXXXX'
}
}
}
When I build my project using jenkins I get the following error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project MyProject: Not authorized. Please check the properties sonar.login and sonar.password.
I would think this is sufficient to analyse the project. Not really sure what am I missing!
Okay I am on SonarQube 7.1 and this is how I did it:
Go to your Jenkins Instance. Click on Manage Jenkins -> Configure System. Scroll down to your SonarQube Server section, either add a new server or edit the existing server to add the token that was generated to the "Server authentication token" field.
In the pipeline script call the specific sonarqube server instance that you added in the previous step and pass the right paramters on command line. I didnt pass the authentication token on the command line as it is already configured within the sonarqube server details in