简体   繁体   中英

SonarQube plugin: how to get property value from command line -D

I am new to sonar plugin development. I wrote a plugin and add PropertyDefine to context. And then I wanna get my property value passed by

gradle sonarqube -Dmy.proper.name=xxx

I don't know what are the next steps? Plz help. Thanks.

All -D parameters can be get by using java.lang.System class:

String valueOrNull = System.getProperty("my.proper.name");

or

String valueOrDefault = System.getProperty("my.proper.name", "defaultValue");

Hi @agabrys thanks for your answer. But I found out that if you wanna get the property from Scanner side , you need make a PostJob like class to deal with it. I didn't clearly know that so I didn't know why I couldn't get that property. Thanks anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM