use of com.epam.pipeline.manager.git.GitlabClient in project cloud-pipeline by epam.
the class SystemPreferences method areGitPreferencesValid.
private boolean areGitPreferencesValid(Map<String, Preference> gitPreferences) {
long adminId = Long.parseLong(gitPreferences.get(GIT_USER_ID.getKey()).getValue());
GitlabClient client = gitManager.getGitlabClient(gitPreferences.get(GIT_HOST.getKey()).getValue(), gitPreferences.get(GIT_TOKEN.getKey()).getValue(), adminId, gitPreferences.get(GIT_USER_NAME.getKey()).getValue());
client.buildCloneCredentials(false, false, 1L);
try {
GitlabVersion version = client.getVersion();
Matcher matcher = GIT_VERSION_PATTERN.matcher(version.getVersion());
if (matcher.find()) {
Integer major = Integer.parseInt(matcher.group(1));
Integer minor = Integer.parseInt(matcher.group(2));
if ((major == 9 && minor >= 5) || (major == 8 && minor < 3)) {
throw new IllegalArgumentException("Invalid git version: " + version.getVersion());
}
} else {
throw new IllegalArgumentException("Invalid git version: " + version.getVersion());
}
} catch (GitClientException e) {
throw new IllegalArgumentException("Could not request Gitlab version", e);
}
return true;
}
Aggregations