Search in sources :

Example 11 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.

the class BuildAssignmentTest method shouldCopyAdditionalDataToBuildAssignment.

@Test
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()).isEqualTo("user1");
    assertThat(buildAssignment.materialRevisions().getRevisions().size()).isEqualTo(materialRevisions.getRevisions().size());
    assertRevisions(buildAssignment, packageMaterialRevision);
    Modification actualModification = buildAssignment.materialRevisions().getRevisions().get(0).getModification(0);
    assertThat(actualModification.getAdditionalData()).isEqualTo(additionalDataAsString);
    assertThat(actualModification.getAdditionalDataMap()).isEqualTo(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.jupiter.api.Test)

Example 12 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.

the class BuildAssignmentTest method shouldNotHaveReferenceToModifiedFilesSinceLargeCommitsCouldCauseBothServerAndAgentsToRunOutOfMemory_MoreoverThisInformationIsNotRequiredOnAgentSide.

@Test
void shouldNotHaveReferenceToModifiedFilesSinceLargeCommitsCouldCauseBothServerAndAgentsToRunOutOfMemory_MoreoverThisInformationIsNotRequiredOnAgentSide() {
    List<Modification> modificationsForSvn = ModificationsMother.multipleModificationList();
    List<Modification> modificationsForHg = ModificationsMother.multipleModificationList();
    MaterialRevision svn = new MaterialRevision(svnMaterial(), modificationsForSvn);
    MaterialRevision hg = new MaterialRevision(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()).isEqualTo("user1");
    assertThat(buildAssignment.materialRevisions().getRevisions().size()).isEqualTo(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.jupiter.api.Test)

Example 13 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.

the class BuildAssignmentTest method shouldInitializeEnvironmentContextFromJobPlan.

@Test
void shouldInitializeEnvironmentContextFromJobPlan() {
    DefaultJobPlan defaultJobPlan = jobForPipeline("foo");
    EnvironmentVariables variables = new EnvironmentVariables();
    variables.add("key1", "value1");
    variables.add("key2", "value2");
    defaultJobPlan.setVariables(variables);
    BuildAssignment buildAssignment = BuildAssignment.create(defaultJobPlan, BuildCause.createManualForced(), new ArrayList<>(), null, null, new ArtifactStores());
    EnvironmentVariableContext context = buildAssignment.initialEnvironmentVariableContext();
    assertThat(context.getProperties().size()).isEqualTo(9);
    assertThat(context.getProperty("key1")).isEqualTo("value1");
    assertThat(context.getProperty("key2")).isEqualTo("value2");
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.jupiter.api.Test)

Example 14 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.

the class BuildAssignmentTest method shouldIntializeEnvironmentContextWithJobPlanEnvironmentVariablesOveridingEnvVariablesFromTheEnvironment.

@Test
void shouldIntializeEnvironmentContextWithJobPlanEnvironmentVariablesOveridingEnvVariablesFromTheEnvironment() {
    DefaultJobPlan defaultJobPlan = jobForPipeline("foo");
    EnvironmentVariables variables = new EnvironmentVariables();
    variables.add("key1", "value_from_job_plan");
    variables.add("key2", "value2");
    defaultJobPlan.setVariables(variables);
    EnvironmentVariableContext contextFromEnvironment = new EnvironmentVariableContext("key1", "value_from_environment");
    contextFromEnvironment.setProperty("key3", "value3", false);
    BuildAssignment buildAssignment = BuildAssignment.create(defaultJobPlan, BuildCause.createManualForced(), new ArrayList<>(), null, contextFromEnvironment, new ArtifactStores());
    EnvironmentVariableContext context = buildAssignment.initialEnvironmentVariableContext();
    assertThat(context.getProperties().size()).isEqualTo(10);
    assertThat(context.getProperty("key1")).isEqualTo("value_from_job_plan");
    assertThat(context.getProperty("key2")).isEqualTo("value2");
    assertThat(context.getProperty("key3")).isEqualTo("value3");
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.jupiter.api.Test)

Example 15 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores 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, -1, new JobIdentifier(PIPELINE_NAME, -2, "1", STAGE_NAME, "1", JOB_NAME), null, new EnvironmentVariables(), new EnvironmentVariables(), null, 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) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Aggregations

ArtifactStores (com.thoughtworks.go.config.ArtifactStores)23 Test (org.junit.jupiter.api.Test)15 ArtifactStore (com.thoughtworks.go.config.ArtifactStore)10 PluggableArtifactConfig (com.thoughtworks.go.config.PluggableArtifactConfig)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7 PublishArtifactResponse (com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse)6 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)6 Builder (com.thoughtworks.go.domain.builder.Builder)4 NullBuilder (com.thoughtworks.go.domain.builder.NullBuilder)4 File (java.io.File)4 ArrayList (java.util.ArrayList)4 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)3 Modification (com.thoughtworks.go.domain.materials.Modification)3 IOException (java.io.IOException)3 Materials (com.thoughtworks.go.config.materials.Materials)2 BuildAssignment (com.thoughtworks.go.remote.work.BuildAssignment)2 BuildWork (com.thoughtworks.go.remote.work.BuildWork)2 GoPublisher (com.thoughtworks.go.work.GoPublisher)2 InOrder (org.mockito.InOrder)2 Gson (com.google.gson.Gson)1