How to put parameter into org.sonar.api.config.Settings from command line?

java
custom_rules
rules

(N.N.) #1

We use Upsource and SonarQube.
Upsource has plugin for integration with Sonar.
It needs some properties from pom file. One of them is sha of commit (sonar.upsource.revision).
So we want extract this property from pom to command line argument.

Upsource plugin implements PostJob and gets pom properties from org.sonar.api.config.Settings.

So, how we can put property sonar.upsource.revision into sonar plugin context dynamically (when run sonar:sonar)?

Upsource plugin https://gist.github.com/szpq0i/0029e0ccccf7af57555eb7400fb8c477#file-pushissuesjob-java-L75


(Janos Gyerik) #2

This may be a dumb suggestion, but have you tried passing -Dsonar.upsource.revision=the-value on the command line of mvn sonar:sonar ?


(N.N.) #3

@janos
of course :slight_smile:

in that case plugin send error, that parameter missed


(N.N.) #4

As you understand, we have source code for plugin and can change it to our needs.
Check link above, it uses Settings to get properties. So… what we can do with that?)


(Julien Henry) #5

Hi,

This @InstantiationStrategy(InstantiationStrategy.PER_TASK) looks suspicious. What if you try to remove it?

Note that this doesn’t really explain why the property would be missing.


(N.N.) #6

It was my mistake, all works fine. Thanks.