Search in sources :

Example 1 with Materials

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);
}
Also used : MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Revision(com.thoughtworks.go.domain.materials.Revision) Materials(com.thoughtworks.go.config.materials.Materials) ArrayList(java.util.ArrayList) Material(com.thoughtworks.go.domain.materials.Material) ModificationVisitorAdapter(com.thoughtworks.go.domain.ModificationVisitorAdapter)

Example 2 with 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));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials)

Example 3 with Materials

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"));
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) Materials(com.thoughtworks.go.config.materials.Materials) ArrayList(java.util.ArrayList) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) BuildWork(com.thoughtworks.go.remote.work.BuildWork) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) ByteArrayInputStream(java.io.ByteArrayInputStream) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) Test(org.junit.Test)

Example 4 with Materials

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));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 5 with Materials

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()));
}
Also used : Materials(com.thoughtworks.go.config.materials.Materials)

Aggregations

Materials (com.thoughtworks.go.config.materials.Materials)70 Test (org.junit.jupiter.api.Test)52 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)31 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)22 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)18 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)17 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)17 Modification (com.thoughtworks.go.domain.materials.Modification)15 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)14 Material (com.thoughtworks.go.domain.materials.Material)14 File (java.io.File)14 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)11 TimeProvider (com.thoughtworks.go.util.TimeProvider)10 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7 Date (java.util.Date)6 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)5 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)5 Stage (com.thoughtworks.go.domain.Stage)5