Search in sources :

Example 1 with Revision

use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.

the class PipelineDocumentTemplateManager method loadPipelineDocumentTemplateWithSpecificVersion.

public PipelineDocumentTemplate loadPipelineDocumentTemplateWithSpecificVersion(Long pipelineId, String version) throws GitClientException {
    Pipeline pipeline = pipelineManager.load(pipelineId);
    List<Revision> revisions = pipelineVersionManager.loadAllVersionFromGit(pipelineId, null);
    Optional<Revision> oRevision = revisions.stream().filter(r -> r.getName().equals(version)).findAny();
    PipelineDocumentTemplate template = oRevision.map(revision -> new PipelineDocumentTemplate(pipeline, revision)).orElseGet(() -> new PipelineDocumentTemplate(pipeline));
    this.fillTemplate(template);
    return template;
}
Also used : PipelineManager(com.epam.pipeline.manager.pipeline.PipelineManager) GitClientException(com.epam.pipeline.exception.git.GitClientException) Date(java.util.Date) Autowired(org.springframework.beans.factory.annotation.Autowired) GitRepositoryEntry(com.epam.pipeline.entity.git.GitRepositoryEntry) DocumentGenerationPropertyManager(com.epam.pipeline.manager.pipeline.DocumentGenerationPropertyManager) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) PipelineVersionManager(com.epam.pipeline.manager.pipeline.PipelineVersionManager) ArrayList(java.util.ArrayList) Service(org.springframework.stereotype.Service) TaskNode(com.epam.pipeline.entity.graph.TaskNode) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) GitManager(com.epam.pipeline.manager.git.GitManager) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Tool(com.epam.pipeline.entity.pipeline.Tool) DataStorageRuleManager(com.epam.pipeline.manager.datastorage.DataStorageRuleManager) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) TaskGraphVO(com.epam.pipeline.controller.vo.TaskGraphVO) Revision(com.epam.pipeline.entity.pipeline.Revision) Optional(java.util.Optional) DataStorageManager(com.epam.pipeline.manager.datastorage.DataStorageManager) DataStorageRule(com.epam.pipeline.entity.datastorage.rules.DataStorageRule) Revision(com.epam.pipeline.entity.pipeline.Revision) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 2 with Revision

use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.

the class GitManagerTest method shouldDeleteFile.

@Test
public void shouldDeleteFile() throws GitClientException {
    final Revision revision = new Revision("Initial commit", "", new Date(), "doesn't matter");
    final Pipeline pipeline = testingPipeline();
    pipeline.setCurrentVersion(revision);
    final GitCommitEntry expectedCommit = new GitCommitEntry();
    givenThat(post(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(expectedCommit))));
    final GitCommitEntry resultingCommit = gitManager.deleteFile(pipeline, DOCS + "/" + README_FILE, pipeline.getCurrentVersion().getCommitId(), "Delete file");
    assertThat(resultingCommit, is(expectedCommit));
}
Also used : Revision(com.epam.pipeline.entity.pipeline.Revision) 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)

Example 3 with Revision

use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.

the class GitManagerTest method shouldFetchRevision.

@Test
public void shouldFetchRevision() throws GitClientException {
    final Pipeline pipeline = testingPipeline();
    final long pageSize = 1;
    final List<GitTagEntry> tags = Collections.emptyList();
    givenThat(get(urlPathEqualTo(api(REPOSITORY_TAGS))).withQueryParam("per_page", equalTo(String.valueOf(pageSize))).willReturn(okJson(with(tags))));
    final GitCommitEntry initialCommit = new GitCommitEntry();
    initialCommit.setMessage("New pipeline initial commit");
    initialCommit.setCreatedAt("2017-07-25T13:13:11Z");
    final List<GitCommitEntry> commits = singletonList(initialCommit);
    givenThat(get(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(commits))));
    final List<Revision> revisions = gitManager.getPipelineRevisions(pipeline, pageSize);
    assertFalse(revisions.isEmpty());
}
Also used : Revision(com.epam.pipeline.entity.pipeline.Revision) GitTagEntry(com.epam.pipeline.entity.git.GitTagEntry) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) GitCommitEntry(com.epam.pipeline.entity.git.GitCommitEntry) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test)

Example 4 with Revision

use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.

the class GitManagerTest method testingPipeline.

/**
 * We suppress checkstyle warning since this method is for creating dummy data that actually doesn't matter.
 */
@SuppressWarnings("checkstyle:MagicNumber")
private Pipeline testingPipeline() {
    final Pipeline pipeline = new Pipeline();
    pipeline.setId(1L);
    pipeline.setRepository(gitHost.withNamespace(ROOT_USER_NAME).withProject(REPOSITORY_NAME).asString());
    final Date date = Date.from(ZonedDateTime.of(2018, 6, 28, 14, 30, 0, 0, UTC).toInstant());
    final Revision revision = new Revision(TEST_REVISION, "Initial commit", date, "somecommitsha");
    pipeline.setCurrentVersion(revision);
    return pipeline;
}
Also used : Revision(com.epam.pipeline.entity.pipeline.Revision) Date(java.util.Date) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 5 with Revision

use of com.epam.pipeline.entity.pipeline.Revision in project cloud-pipeline by epam.

the class GitManager method createPipelineRevision.

public Revision createPipelineRevision(Pipeline pipeline, String revisionName, String commit, String message, String releaseDescription) throws GitClientException {
    Assert.isTrue(GitUtils.checkGitNaming(revisionName), messageHelper.getMessage(MessageConstants.ERROR_INVALID_PIPELINE_REVISION_NAME, revisionName));
    GitlabClient client = this.getGitlabClientForPipeline(pipeline);
    GitTagEntry gitTagEntry = client.createRepositoryRevision(revisionName, commit, message, releaseDescription);
    return new Revision(gitTagEntry.getName(), gitTagEntry.getMessage(), parseGitDate(gitTagEntry.getCommit().getAuthoredDate()), gitTagEntry.getCommit().getId());
}
Also used : Revision(com.epam.pipeline.entity.pipeline.Revision) GitTagEntry(com.epam.pipeline.entity.git.GitTagEntry)

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