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;
}
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));
}
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());
}
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;
}
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());
}
Aggregations