use of com.epam.pipeline.exception.git.GitClientException in project cloud-pipeline by epam.
the class PipelineManager method delete.
@Transactional(propagation = Propagation.REQUIRED)
public Pipeline delete(Long id, boolean keepRepository) {
Pipeline pipeline = load(id);
if (!keepRepository) {
try {
gitManager.deletePipelineRepository(pipeline);
} catch (GitClientException | UnsupportedEncodingException | URISyntaxException | HttpClientErrorException e) {
LOGGER.error(e.getMessage(), e);
}
}
runLogDao.deleteLogsForPipeline(id);
restartRunManager.deleteRestartedRunsForPipeline(id);
runStatusManager.deleteRunStatusForPipeline(id);
pipelineRunDao.deleteRunsByPipeline(id);
dataStorageRuleDao.deleteRulesByPipeline(id);
pipelineDao.deletePipeline(id);
return pipeline;
}
use of com.epam.pipeline.exception.git.GitClientException 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;
}
use of com.epam.pipeline.exception.git.GitClientException in project cloud-pipeline by epam.
the class GitManagerTest method shouldFetchPipelineDocs.
@Test
public void shouldFetchPipelineDocs() throws GitClientException {
final Pipeline pipeline = testingPipeline();
final GitRepositoryEntry bla = new GitRepositoryEntry();
bla.setName(README_FILE);
bla.setType(BLOB_TYPE);
final List<GitRepositoryEntry> tree = singletonList(bla);
givenThat(get(urlPathEqualTo(api(REPOSITORY_TREE))).withQueryParam(REF_NAME, equalTo(TEST_REVISION)).withQueryParam(PATH, equalTo(DOCS + "/")).withQueryParam(RECURSIVE, equalTo(String.valueOf(false))).willReturn(okJson(with(tree))));
final GitTagEntry tag = new GitTagEntry();
givenThat(get(urlPathEqualTo(api(REPOSITORY_TAGS + "/" + TEST_REVISION))).willReturn(okJson(with(tag))));
final List<GitRepositoryEntry> repoEntries = gitManager.getPipelineDocs(pipeline.getId(), TEST_REVISION);
final boolean noEntries = repoEntries.isEmpty();
final boolean docsOnly = repoEntries.stream().filter(e -> !e.getName().startsWith(".")).allMatch(e -> e.getName().endsWith(".md"));
assertFalse(noEntries);
assertTrue(docsOnly);
}
Aggregations