use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.
the class PipelineLoader method fetchEntity.
@Override
protected PipelineDoc fetchEntity(final Long id) {
Pipeline pipeline = getApiClient().loadPipeline(String.valueOf(id));
List<Revision> revisions = getApiClient().loadPipelineVersions(pipeline.getId()).stream().filter(revision -> !revision.getName().startsWith(DRAFT_VERSION)).collect(Collectors.toList());
PipelineDoc.PipelineDocBuilder pipelineDocBuilder = PipelineDoc.builder().pipeline(pipeline).revisions(revisions);
return pipelineDocBuilder.build();
}
use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.
the class PipelineCodeHandlerTest method setup.
@BeforeEach
void setup() {
pipelineCodeHandler = new PipelineCodeHandler(INDEX_PREFIX, INDEX_NAME, apiClient, new ElasticIndexService(), FILE_INDEX_PATHS, objectMapper, pipelineLoader, new PipelineCodeMapper(), "master");
expectedPipelineEvent = new PipelineEvent();
expectedPipelineEvent.setEventType(EventType.INSERT);
expectedPipelineEvent.setObjectType(PipelineEvent.ObjectType.PIPELINE);
expectedPipelineEvent.setObjectId(1L);
expectedPipelineEvent.setCreatedDate(LocalDateTime.now());
expectedPipelineEvent.setData("{\"tag\": {\"type\": \"string\", \"value\": \"admin\"}}");
pipeline = new Pipeline();
pipeline.setId(1L);
pipeline.setName(TEST_NAME);
pipeline.setCreatedDate(DateUtils.now());
pipeline.setParentFolderId(2L);
pipeline.setDescription(TEST_DESCRIPTION);
pipeline.setRepository(TEST_REPO);
pipeline.setTemplateId(TEST_TEMPLATE);
Revision revision = new Revision();
revision.setName(TEST_VERSION);
PipelineDoc pipelineDoc = PipelineDoc.builder().pipeline(pipeline).revisions(Collections.singletonList(revision)).build();
gitPushEventData = new GitEventData();
gitPushEventData.setGitEventType(GitEventType.push);
gitPushEventData.setPaths(Collections.singletonList(FILE_INDEX_PATHS));
gitPushEventData.setVersion(VERSION);
gitTagEventData = new GitEventData();
gitTagEventData.setGitEventType(GitEventType.tag_push);
gitTagEventData.setPaths(Collections.singletonList(FILE_INDEX_PATHS));
gitTagEventData.setVersion(VERSION);
gitRepositoryEntry = new GitRepositoryEntry();
gitRepositoryEntry.setId("1");
gitRepositoryEntry.setName(TEST_NAME);
gitRepositoryEntry.setPath(FOLDER_INDEX_PATHS);
gitRepositoryEntry.setType("blob");
container = EntityContainer.<PipelineDoc>builder().entity(pipelineDoc).owner(USER).metadata(METADATA).permissions(PERMISSIONS_CONTAINER).build();
}
use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.
the class GitManager method getPipelineRevisions.
public List<Revision> getPipelineRevisions(Pipeline pipeline, Long pageSize) throws GitClientException {
GitlabClient client = this.getGitlabClientForPipeline(pipeline);
List<Revision> tags = client.getRepositoryRevisions(pageSize).stream().map(i -> new Revision(i.getName(), i.getMessage(), parseGitDate(i.getCommit().getAuthoredDate()), i.getCommit().getId())).sorted(Comparator.comparing(Revision::getCreatedDate).reversed()).collect(Collectors.toList());
List<Revision> revisions = new ArrayList<>(tags.size());
addDraftRevision(client, revisions, tags);
CollectionUtils.addAll(revisions, tags);
return revisions;
}
use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.
the class PipelineDocumentTemplateManager method applyChangeSummary.
private void applyChangeSummary(PipelineDocumentTemplate template) {
try {
List<Revision> revisions = pipelineVersionManager.loadAllVersionFromGit(template.getPipeline().getId(), null);
Revision previousRevision = null;
for (int i = 0; i < revisions.size(); i++) {
if (revisions.get(i).getName().equals(template.getVersion().getName())) {
if (i < revisions.size() - 1) {
previousRevision = revisions.get(i + 1);
}
break;
}
}
if (previousRevision != null) {
final Long oneSecond = 1000L;
Date since = new Date(previousRevision.getCreatedDate().getTime() + oneSecond);
template.setCommits(gitManager.getCommits(template.getPipeline(), template.getVersion().getName(), since));
} else {
template.setCommits(gitManager.getCommits(template.getPipeline(), template.getVersion().getName()));
}
} catch (GitClientException e) {
log.error(e.getMessage(), e);
}
}
use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.
the class GitManagerTest method getConfigFile.
@Test
public void getConfigFile() {
final Pipeline pipeline = testingPipeline();
final String sha = "somecommitsha";
final Revision revision = new Revision("Initial commit", "", new Date(), DRAFT_PREFIX + sha);
pipeline.setCurrentVersion(revision);
final GitCommitEntry initialCommit = new GitCommitEntry();
initialCommit.setMessage("New pipeline initial commit");
initialCommit.setCreatedAt("2017-07-25T13:13:11Z");
initialCommit.setId(sha);
givenThat(get(urlPathEqualTo(api(REPOSITORY_COMMITS + "/" + initialCommit.getId()))).willReturn(okJson(with(initialCommit))));
final GitTagEntry tag = new GitTagEntry();
tag.setName(TEST_REVISION);
givenThat(get(urlPathEqualTo(api(REPOSITORY_TAGS + "/" + tag.getName()))).willReturn(okJson(with(tag))));
final File file = gitManager.getConfigFile(pipeline, pipeline.getCurrentVersion().getCommitId());
assertThat(file.getParentFile().exists(), is(true));
}
Aggregations