Search in sources :

Example 86 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class BuildComposerTest method getAssigment.

private static BuildAssignment getAssigment(String jobXml, String pipelineName, boolean fetchMaterials, boolean cleanWorkingDir) throws Exception {
    CruiseConfig cruiseConfig = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(withJob(jobXml, pipelineName)).config;
    JobConfig jobConfig = cruiseConfig.jobConfigByName(pipelineName, STAGE_NAME, JOB_PLAN_NAME, true);
    JobPlan jobPlan = JobInstanceMother.createJobPlan(jobConfig, new JobIdentifier(pipelineName, -2, PIPELINE_LABEL, STAGE_NAME, String.valueOf(STAGE_COUNTER), JOB_PLAN_NAME, 0L), new DefaultSchedulingContext());
    jobPlan.setFetchMaterials(fetchMaterials);
    jobPlan.setCleanWorkingDir(cleanWorkingDir);
    final Stage stage = StageMother.custom(STAGE_NAME, new JobInstance(JOB_PLAN_NAME));
    BuildCause buildCause = BuildCause.createWithEmptyModifications();
    final Pipeline pipeline = new Pipeline(pipelineName, buildCause, stage);
    pipeline.setLabel(PIPELINE_LABEL);
    List<Builder> builder = builderFactory.buildersForTasks(pipeline, jobConfig.getTasks(), resolver);
    return BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, pipeline.defaultWorkingFolder(), null, new ArtifactStores());
}
Also used : Builder(com.thoughtworks.go.domain.builder.Builder) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 87 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class BuildAssignmentTest method shouldCopyAdditionalDataToBuildAssignment.

@Test
public void shouldCopyAdditionalDataToBuildAssignment() {
    MaterialRevision packageMaterialRevision = ModificationsMother.createPackageMaterialRevision("revision");
    Map<String, String> additionalData = new HashMap<>();
    additionalData.put("a1", "v1");
    additionalData.put("a2", "v2");
    String additionalDataAsString = new Gson().toJson(additionalData);
    packageMaterialRevision.getModifications().first().setAdditionalData(additionalDataAsString);
    MaterialRevisions materialRevisions = new MaterialRevisions(packageMaterialRevision);
    BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, "user1");
    BuildAssignment buildAssignment = BuildAssignment.create(jobForPipeline("foo"), buildCause, new ArrayList<>(), null, null, new ArtifactStores());
    assertThat(buildAssignment.getBuildApprover(), is("user1"));
    assertThat(buildAssignment.materialRevisions().getRevisions().size(), is(materialRevisions.getRevisions().size()));
    assertRevisions(buildAssignment, packageMaterialRevision);
    Modification actualModification = buildAssignment.materialRevisions().getRevisions().get(0).getModification(0);
    assertThat(actualModification.getAdditionalData(), is(additionalDataAsString));
    assertThat(actualModification.getAdditionalDataMap(), is(additionalData));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) Gson(com.google.gson.Gson) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 88 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class BuildAssignmentTest method shouldNotHaveReferenceToModifiedFilesSinceLargeCommitsCouldCauseBothServerAndAgentsToRunOutOfMemory_MoreoverThisInformationIsNotRequiredOnAgentSide.

@Test
public void shouldNotHaveReferenceToModifiedFilesSinceLargeCommitsCouldCauseBothServerAndAgentsToRunOutOfMemory_MoreoverThisInformationIsNotRequiredOnAgentSide() {
    List<Modification> modificationsForSvn = ModificationsMother.multipleModificationList();
    List<Modification> modificationsForHg = ModificationsMother.multipleModificationList();
    MaterialRevision svn = new MaterialRevision(MaterialsMother.svnMaterial(), modificationsForSvn);
    MaterialRevision hg = new MaterialRevision(MaterialsMother.hgMaterial(), modificationsForHg);
    MaterialRevisions materialRevisions = new MaterialRevisions(svn, hg);
    BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, "user1");
    BuildAssignment buildAssignment = BuildAssignment.create(jobForPipeline("foo"), buildCause, new ArrayList<>(), null, null, new ArtifactStores());
    assertThat(buildAssignment.getBuildApprover(), is("user1"));
    assertThat(buildAssignment.materialRevisions().getRevisions().size(), is(materialRevisions.getRevisions().size()));
    assertRevisions(buildAssignment, svn);
    assertRevisions(buildAssignment, hg);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 89 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class BuildWorkArtifactUploadingTest method createAssignment.

private BuildAssignment createAssignment(List<ArtifactPlan> artifactPlans, String[] fileToCreate) throws IOException {
    MaterialRevisions materialRevisions = materialRevisions();
    BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, "");
    List<Builder> builders = new ArrayList<>();
    builders.add(new CreateFileBuilder(fileToCreate));
    DefaultJobPlan plan = new DefaultJobPlan(new Resources(), artifactPlans, new ArrayList<>(), -1, new JobIdentifier(PIPELINE_NAME, -2, "1", STAGE_NAME, "1", JOB_NAME), null, new EnvironmentVariables(), new EnvironmentVariables(), null);
    return BuildAssignment.create(plan, buildCause, builders, buildWorkingDirectory, new EnvironmentVariableContext(), new ArtifactStores());
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) Builder(com.thoughtworks.go.domain.builder.Builder) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder) ArrayList(java.util.ArrayList) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext)

Example 90 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method createAssignment.

private BuildAssignment createAssignment(EnvironmentVariableContext environmentVariableContext) throws IOException {
    JobPlan plan = new DefaultJobPlan(new Resources(), new ArrayList<>(), new ArrayList<>(), -1, new JobIdentifier(PIPELINE_NAME, 1, "1", STAGE_NAME, "1", JOB_NAME, 123L), null, new EnvironmentVariables(), new EnvironmentVariables(), null);
    MaterialRevisions materialRevisions = materialRevisions();
    BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, TRIGGERED_BY_USER);
    List<Builder> builders = new ArrayList<>();
    builders.add(new CommandBuilder("ant", "", dir, new RunIfConfigs(), new NullBuilder(), ""));
    return BuildAssignment.create(plan, buildCause, builders, dir, environmentVariableContext, new ArtifactStores());
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder) ArrayList(java.util.ArrayList) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder)

Aggregations

BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)158 Test (org.junit.Test)115 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)33 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)32 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)31 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)31 TimeProvider (com.thoughtworks.go.util.TimeProvider)28 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)21 Modification (com.thoughtworks.go.domain.materials.Modification)21 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)16 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)16 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)14 Date (java.util.Date)14 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)13 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)12 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)11 Username (com.thoughtworks.go.server.domain.Username)10 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)10 Builder (com.thoughtworks.go.domain.builder.Builder)9