use of hudson.plugins.sonar.utils.Version in project sonar-scanner-jenkins by SonarSource.
the class SQProjectResolver method resolve.
/**
* Resolve information concerning the quality gate.
* Might return null if it's not possible to fetch it, which should be interpreted as 'nothing to display'.
* Errors that should be displayed are included in {@link ProjectInformation#getErrors()}.
*/
@CheckForNull
public ProjectInformation resolve(@Nullable String serverUrl, @Nullable String projectDashboardUrl, String ceTaskId, String installationName) {
SonarInstallation inst = SonarInstallation.get(installationName);
if (inst == null) {
Logger.LOG.info(() -> "Invalid installation name: " + installationName);
return null;
}
if (serverUrl == null) {
Logger.LOG.info("No server url.");
return null;
}
try {
WsClient wsClient = new WsClient(client, serverUrl, inst.getServerAuthenticationToken());
Version version = new Version(wsClient.getServerVersion());
if (version.compareTo(new Version("5.6")) < 0) {
Logger.LOG.info(() -> "SQ < 5.6 is not supported");
return null;
}
ProjectInformation projectInfo = new ProjectInformation();
projectInfo.setUrl(projectDashboardUrl);
String analysisId = requestCETaskDetails(wsClient, projectInfo, ceTaskId);
if (analysisId != null) {
projectInfo.setStatus(wsClient.requestQualityGateStatus(analysisId));
}
return projectInfo;
} catch (Exception e) {
Logger.LOG.log(Level.WARNING, "Error fetching project information", e);
return null;
}
}
Aggregations