Search in sources :

Example 6 with Revision

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();
}
Also used : AbstractCloudPipelineEntityLoader(com.epam.pipeline.elasticsearchagent.service.impl.converter.AbstractCloudPipelineEntityLoader) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Component(org.springframework.stereotype.Component) List(java.util.List) PipelineDoc(com.epam.pipeline.elasticsearchagent.model.PipelineDoc) CloudPipelineAPIClient(com.epam.pipeline.elasticsearchagent.service.impl.CloudPipelineAPIClient) Revision(com.epam.pipeline.entity.pipeline.Revision) AclClass(com.epam.pipeline.entity.security.acl.AclClass) Collectors(java.util.stream.Collectors) Revision(com.epam.pipeline.entity.pipeline.Revision) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) PipelineDoc(com.epam.pipeline.elasticsearchagent.model.PipelineDoc)

Example 7 with Revision

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();
}
Also used : GitEventData(com.epam.pipeline.elasticsearchagent.model.git.GitEventData) PipelineCodeMapper(com.epam.pipeline.elasticsearchagent.service.impl.converter.pipeline.PipelineCodeMapper) PipelineEvent(com.epam.pipeline.elasticsearchagent.model.PipelineEvent) Revision(com.epam.pipeline.entity.pipeline.Revision) GitRepositoryEntry(com.epam.pipeline.entity.git.GitRepositoryEntry) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) PipelineDoc(com.epam.pipeline.elasticsearchagent.model.PipelineDoc) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with Revision

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;
}
Also used : Revision(com.epam.pipeline.entity.pipeline.Revision) ArrayList(java.util.ArrayList)

Example 9 with Revision

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);
    }
}
Also used : Revision(com.epam.pipeline.entity.pipeline.Revision) GitClientException(com.epam.pipeline.exception.git.GitClientException) Date(java.util.Date)

Example 10 with Revision

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));
}
Also used : Revision(com.epam.pipeline.entity.pipeline.Revision) IsEmptyString.isEmptyString(org.hamcrest.text.IsEmptyString.isEmptyString) Matchers.anyString(org.mockito.Matchers.anyString) GitTagEntry(com.epam.pipeline.entity.git.GitTagEntry) GitFile(com.epam.pipeline.entity.git.GitFile) File(java.io.File) Date(java.util.Date) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) GitCommitEntry(com.epam.pipeline.entity.git.GitCommitEntry) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test)

Aggregations

Revision (com.epam.pipeline.entity.pipeline.Revision)14 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)11 PipelineDoc (com.epam.pipeline.elasticsearchagent.model.PipelineDoc)5 Date (java.util.Date)5 GitCommitEntry (com.epam.pipeline.entity.git.GitCommitEntry)4 GitTagEntry (com.epam.pipeline.entity.git.GitTagEntry)4 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)4 Test (org.junit.Test)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 EntityContainer (com.epam.pipeline.elasticsearchagent.model.EntityContainer)2 PipelineEvent (com.epam.pipeline.elasticsearchagent.model.PipelineEvent)2 GitRepositoryEntry (com.epam.pipeline.entity.git.GitRepositoryEntry)2 GitClientException (com.epam.pipeline.exception.git.GitClientException)2 ArrayList (java.util.ArrayList)2 Slf4j (lombok.extern.slf4j.Slf4j)2 IsEmptyString.isEmptyString (org.hamcrest.text.IsEmptyString.isEmptyString)2 Test (org.junit.jupiter.api.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 TaskGraphVO (com.epam.pipeline.controller.vo.TaskGraphVO)1