Reputation: 348
Hi I'm trying to analyse java maven project with sonarQube scanner for Jenkins, using method described in here: SonarQube Scanner Documentation, now in the section Analyzing with SonarQube Scanner for Maven, there it says that into created Jenkins maven job you just need to add into goals: $SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL
It looked like this: Build Image
Now I did this, you can also find more of those environmental variables after clicking on the blue question mark right next to prepare sonarQube scanner environment in the build environment section.
It worked and has analyzed one gitlab repository which I have specified within Source Code Management in the Source Code Management.
When I, however, tried to change this to another repository, firstly It just analyzed the same repository I had specified before and it ran an analysis on the old one and also sent results from the old one to my SonarQube server, it completely ignored that I specified different gitlab repository in the Source code management part.
Later on, I tried to add clean install option to maven goals, it has thrown an error at the end of the build output console:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar (default-cli) on project Export: Please provide compiled classes of your project with sonar.java.binaries property -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
So this brings me to a part where I think I'm doing something wrong about the configuration of environmental variables, I don't understand what are the actual values of $SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL or any other environmental variables.
My final goal is to be able to analyze Gitlab repositories with java maven projects, from Jenkins.
Upvotes: 0
Views: 1104
Reputation: 17009
You can trigger SonarQube analysis after building your project with a standard Jenkins Build Step, see Analyzing with SonarQube Scanner for Jenkins:
Features
This plugin lets you centralize the configuration of SonarQube server connection details in Jenkins global configuration.
Then you can trigger SonarQube analysis from Jenkins using standard Jenkins Build Steps to trigger analysis with:
- SonarQube Scanner
- SonarQube Scanner for Maven
- SonarQube Scanner for MSBuild
or with a Post-build Action, see Analyzing with SonarQube Scanner for Maven:
The Post-build Action for Maven analysis is still available, but is deprecated.
Using a Freestyle project you could add a build step for SonarQube analysis like:
Using a Maven project (Maven Integration) you could add a Post-build Action for SonarQube analysis like:
Upvotes: 1