通过Sonarqube wsClient从Sonarqube获取属性
我想通过wsclient获取通过Sonarqube wsClient从Sonarqube获取属性,sonarqube,Sonarqube,我想通过wsclient获取sonar.timemachine.period1。 看到没有,我决定自己烤一个 private Map<String, String> retrievePeriodProperties(final WsClient wsClient, int requestedPeriod) { if (requestedPeriod > 0) { final WsRequest propertiesWsRequestPeriod =
sonar.timemachine.period1
。
看到没有,我决定自己烤一个
private Map<String, String> retrievePeriodProperties(final WsClient wsClient, int requestedPeriod) {
if (requestedPeriod > 0) {
final WsRequest propertiesWsRequestPeriod =
new GetRequest("api/properties/sonar.timemachine.period" + requestedPeriod);
final WsResponse propertiesWsResponsePeriod =
wsClient.wsConnector().call(propertiesWsRequestPeriod);
if (propertiesWsResponsePeriod.isSuccessful()) {
String resp = propertiesWsResponsePeriod.content();
Map<String, String> map = new HashMap<>();
map.put(Integer.toString(requestedPeriod), resp);
return map;
}
}
return new HashMap<>();
}
private-Map-retrievePeriodProperties(最终WsClient-WsClient,int-requestedPeriod){
如果(requestedPeriod>0){
最终WsRequest属性WSRequestPeriod=
新的GetRequest(“api/properties/sonar.timemachine.period”+requestedPeriod);
最终WsResponse属性WSResponsePeriod=
wsClient.wsConnector().call(propertiesWsRequestPeriod);
if(propertiesWsResponsePeriod.isSuccessful()){
String resp=propertiesWsResponsePeriod.content();
Map Map=newhashmap();
map.put(Integer.toString(requestedPeriod),resp);
返回图;
}
}
返回新的HashMap();
}
但它总是返回一个空的Map
你可以使用
org.sonar.api.config.Settings
获取SonarQube中定义的属性。你可以使用org.sonar.api.config.Settings
获取SonarQube中定义的属性。SonarQube的版本是什么?hi@Teryk SonarQube,我正在运行LTS SonarQube。如下所述,我已经通过org.sonar.api.config.Settings
成功访问了它们。我明天把它标为答案。谢谢你的回复!SonarQube的版本是什么?嗨@Teryk SonarSource,我正在运行LTS SonarQube。如下所述,我已经通过org.sonar.api.config.Settings
成功访问了它们。我明天把它标为答案。谢谢你的回复!