Hi,
I’m developing a custom sonar plugin.
In this, I’m creating a sonar webservice, which collects data from sonar Rest APIs, performs some other actions and returns a consolidated results.
Now we have multiple sonar instances where I want to install this plugin.
Like: dev-myinstance-sonar.com or prod-myinstance-sonar.com
While calling sonar’s internal REST call (say api/measures/component
), I cannot tell if the base URL will be dev or prod.
So how should I make call only providing the API path, without providing base URL?
Sample code:
import org.sonarqube.ws.WsMeasures;
public class MyPlgin implements WebService {
@Override
public void define(Context context) {
// Call REST api
String urlStr = "/api/measures/component"; <--- This doesn't work. Sonar throws Malformed url exception.
URL url = new URL(urlStr);
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
......
}
}
Please suggest.
Thanks