use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class ArtifactsPublisherTest method shouldDeletePluggableArtifactMetadataDirectory.
@Test
public void shouldDeletePluggableArtifactMetadataDirectory() throws Exception {
TestFileUtil.createTestFile(workingFolder, "installer.zip");
TestFileUtil.createTestFile(workingFolder, "testreports.xml");
final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
List<ArtifactPlan> artifactPlans = Arrays.asList(new ArtifactPlan(ArtifactPlanType.file, "installer.zip", "dist"), new ArtifactPlan(ArtifactPlanType.unit, "testreports.xml", "testreports"), artifactPlan);
when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
final GoPublisher publisher = mock(GoPublisher.class);
assertThat(Arrays.asList(workingFolder.list()), containsInAnyOrder("testreports.xml", "installer.zip", "cruise-output"));
new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(artifactPlans, env);
assertThat(Arrays.asList(workingFolder.list()), containsInAnyOrder("testreports.xml", "installer.zip", "cruise-output"));
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class ArtifactsPublisherTest method shouldUploadFilesCorrectly.
@Test
public void shouldUploadFilesCorrectly() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
final File src1 = TestFileUtil.createTestFolder(workingFolder, "src1");
TestFileUtil.createTestFile(src1, "test.txt");
artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, src1.getName(), "dest"));
final File src2 = TestFileUtil.createTestFolder(workingFolder, "src2");
TestFileUtil.createTestFile(src1, "test.txt");
artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, src2.getName(), "test"));
StubGoPublisher publisher = new StubGoPublisher();
new ArtifactsPublisher(publisher, artifactExtension, new ArtifactStores(), registry, workingFolder).publishArtifacts(artifactPlans, env);
Map<File, String> expectedFiles = new HashMap<File, String>() {
{
put(src1, "dest");
put(src2, "test");
}
};
assertThat(publisher.publishedFiles(), is(expectedFiles));
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class ArtifactsPublisherTest method shouldAddPluggableArtifactMetadataFileArtifactPlanAtTop.
@Test
public void shouldAddPluggableArtifactMetadataFileArtifactPlanAtTop() throws Exception {
TestFileUtil.createTestFile(workingFolder, "installer.zip");
TestFileUtil.createTestFile(workingFolder, "testreports.xml");
final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
List<ArtifactPlan> artifactPlans = Arrays.asList(new ArtifactPlan(ArtifactPlanType.file, "installer.zip", "dist"), new ArtifactPlan(ArtifactPlanType.unit, "testreports.xml", "testreports"), artifactPlan);
when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
final GoPublisher publisher = mock(GoPublisher.class);
new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(artifactPlans, env);
InOrder inOrder = inOrder(publisher);
inOrder.verify(publisher).upload(any(), eq("pluggable-artifact-metadata"));
inOrder.verify(publisher).upload(any(), eq("dist"));
inOrder.verify(publisher).upload(any(), eq("testreports"));
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method getBuildWorkWithP4MaterialRevision.
private BuildWork getBuildWorkWithP4MaterialRevision(P4Material p4Material) {
pipelineConfig.setMaterialConfigs(new Materials(p4Material).convertToConfigs());
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 = new MaterialRevisions(new MaterialRevision(p4Material, new Modification("user", "comment", "a@b.com", new Date(), "10")));
BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, TRIGGERED_BY_USER);
List<Builder> builders = new ArrayList<>();
builders.add(new CommandBuilder("ant", "", dir, new RunIfConfigs(), new NullBuilder(), ""));
BuildAssignment assignment = BuildAssignment.create(plan, buildCause, builders, dir, environmentVariableContext, new ArtifactStores());
return new BuildWork(assignment, systemEnvironment.consoleLogCharset());
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class BuildAssignmentTest method shouldInitializeEnvironmentContextFromJobPlanWithTriggerVariablesOverridingEnvVariablesFromJob.
@Test
void shouldInitializeEnvironmentContextFromJobPlanWithTriggerVariablesOverridingEnvVariablesFromJob() {
DefaultJobPlan defaultJobPlan = jobForPipeline("foo");
EnvironmentVariables triggerVariables = new EnvironmentVariables();
triggerVariables.add("key1", "override");
triggerVariables.add("key3", "value3");
EnvironmentVariables variables = new EnvironmentVariables();
variables.add("key1", "value1");
variables.add("key2", "value2");
defaultJobPlan.setTriggerVariables(triggerVariables);
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("override");
assertThat(context.getProperty("key2")).isEqualTo("value2");
}
Aggregations