I’m using SonarQube 8.1 (Developer Edition) and Jenkins to analyse Maven projects which source code is hosted on Bitbucket.
I’m using the “Pull Request Decoration” functionality and it’s working well. However, to configure this functionality, I had to set these parameters manually (through the GUI, in project page : Administration > General Settings > Pull Request Decoration) :
- Configuration name
- Project key
- Repository SLUG
Is it possible to set these parameters through command line (e.g in
mvn command, I’d expect something like
mvn clean -Psonar $SONAR_MAVEN_GOAL -Dsonar.pullrequest.decoration.configurationname=<my-conf-name> -Dsonar.pullrequest.decoration.projectkey=<my-project-key> -Dsonar.pullrequest.decoration.repositoryslug=<my-repository-slug>) or throught REST API ?
Welcome to the community forum!
No, this is not possible to define this from the scanner. Thoses are project-level parameters, they won’t change from one analysis to the next one, so better not pollute your scanner with static parameters.
You can indeed define them with the rest API. Have a look at the
api/alm_settings/set_bitbucket_binding entry in your web api documentation!
i already have a bunch of projects in sonarqube, so having to go through and manually configure this and/or touch the api is crappy.
i would prefer to have the option to specify these values as properties to the scanner even if they are ignored on subsequent runs.
I kinda don’t understand why have you removed a great functionality from Sonar. Why do you forbid user adding these parameters to scanner? If, as you said, I don’t want to pollute my scanner with these parameters, I would add these options to project in Sonar UI. But, I have many projects in my Sonar and adding them manually seems awful.
Plus, what about new projects (when I perform analyse on Sonar for first time)? Do I have to manually add Project Key and Repository SLUG in the UI for every new project? I did it before in pipeline, and I really hope I don’t have to implement new API queries to update these settings. If so, I don’t see any reasons to update Sonar.
For the ALM integration I could use the REST endpoint but what about the Pull Request Decoration per project?
We have ~1200 projects, configuring all of them in SonarQube is total torture…
So we have to build automation around SonarQube just because you can’t pass those 2-3 parameters to the scanner?
Hey, actually defining the “binding” at the project level (with the API) will enable the PR decoration for this project.