use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class BuildCause method materials.
public Materials materials() {
final List<Material> materials = new ArrayList<>();
materialRevisions.accept(new ModificationVisitorAdapter() {
public void visit(Material material, Revision revision) {
materials.add(material);
}
});
return new Materials(materials);
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class MaterialExpansionServiceTest method shouldNotExpandGitSubmodulesIntoMultipleMaterialsWhenExpandingGitMaterialForScheduling.
@Test
public void shouldNotExpandGitSubmodulesIntoMultipleMaterialsWhenExpandingGitMaterialForScheduling() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
submoduleRepos.addSubmodule("submodule-1", "sub1");
GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
when(materialConfigConverter.toMaterials(new MaterialConfigs(gitMaterial.config()))).thenReturn(new Materials(gitMaterial));
Materials materials = new Materials();
materialExpansionService.expandForScheduling(gitMaterial, materials);
assertThat(materials.size(), is(1));
assertThat(materials.get(0), is(gitMaterial));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class MessageTest method encodeAndDecodeAssignWorkWithDifferentBuilders.
@Test
public void encodeAndDecodeAssignWorkWithDifferentBuilders() throws Exception {
File workingDir = new File(CruiseConfig.WORKING_BASE_DIR + "pipelineName");
Materials materials = MaterialsMother.defaultMaterials();
MaterialRevisions revisions = ModificationsMother.modifyOneFile(materials, ModificationsMother.nextRevision());
BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
List<Builder> builder = new ArrayList<>();
builder.add(new CommandBuilder("command", "args", workingDir, new RunIfConfigs(), new NullBuilder(), "desc"));
builder.add(new BuilderForKillAllChildTask());
builder.add(new CommandBuilderWithArgList("command", new String[] { "arg1", "arg2" }, workingDir, new RunIfConfigs(), new NullBuilder(), "desc"));
builder.add(new FetchArtifactBuilder(new RunIfConfigs(), new NullBuilder(), "desc", jobPlan().getIdentifier(), "srcdir", "dest", new FileHandler(workingDir, "src"), new ChecksumFileHandler(workingDir)));
BuildAssignment assignment = BuildAssignment.create(jobPlan(), buildCause, builder, workingDir, new EnvironmentVariableContext(), new ArtifactStores());
BuildWork work = new BuildWork(assignment, "utf-8");
byte[] msg = MessageEncoding.encodeMessage(new Message(Action.assignWork, MessageEncoding.encodeWork(work)));
Message decodedMsg = MessageEncoding.decodeMessage(new ByteArrayInputStream(msg));
BuildWork decodedWork = (BuildWork) MessageEncoding.decodeWork(decodedMsg.getData());
assertThat(decodedWork.getAssignment().getJobIdentifier().getPipelineName(), is("pipelineName"));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class MixedMultipleMaterialsTest method shouldGetLatestModificationswithThreeRepositories.
@Test
public void shouldGetLatestModificationswithThreeRepositories() throws Exception {
HgMaterial hgMaterial = hgRepo.material();
SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
GitMaterial gitMaterial = gitRepo.createMaterial();
Materials materials = new Materials(hgMaterial, svnMaterial, gitMaterial);
MaterialRevisions revisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
assertThat(revisions.getMaterialRevision(0).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(0).getRevision(), is(new Modifications(hgRepo.latestModifications()).latestRevision(hgMaterial)));
assertThat(revisions.getMaterialRevision(1).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(1).getRevision(), is(latestRevision(svnMaterial, pipelineDir, new TestSubprocessExecutionContext())));
assertThat(revisions.getMaterialRevision(2).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(2).getRevision(), is(new Modifications(gitRepo.latestModifications()).latestRevision(gitMaterial)));
assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(3));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class BuildComposer method updateMaterials.
private BuildCommand updateMaterials() {
if (!assignment.shouldFetchMaterials()) {
return echoWithPrefix("Skipping material update since stage is configured not to fetch materials");
}
MaterialRevisions materialRevisions = assignment.materialRevisions();
Materials materials = materialRevisions.getMaterials();
return BuildCommand.compose(materials.cleanUpCommand(workingDirectory()), echoWithPrefix("Start to update materials \n"), materialRevisions.updateToCommand(workingDirectory()));
}
Aggregations