use of com.thoughtworks.go.config.ArtifactStores 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.ArtifactStores in project gocd by gocd.
the class UpdateArtifactStoreConfigCommand method update.
@Override
public void update(CruiseConfig modifiedConfig) {
ArtifactStore existingArtifactStore = findExistingProfile(modifiedConfig);
ArtifactStores artifactStores = getPluginProfiles(modifiedConfig);
artifactStores.set(artifactStores.indexOf(existingArtifactStore), profile);
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class BuildAssignmentTest method createAssignment.
private BuildAssignment createAssignment(EnvironmentVariableContext environmentVariableContext, BuildCause buildCause) {
JobPlan plan = new DefaultJobPlan(new Resources(), new ArrayList<>(), -1, new JobIdentifier(PIPELINE_NAME, 1, "1", STAGE_NAME, "1", JOB_NAME, 123L), null, new EnvironmentVariables(), new EnvironmentVariables(), null, null);
List<Builder> builders = new ArrayList<>();
builders.add(new CommandBuilder("ls", "", null, new RunIfConfigs(), new NullBuilder(), ""));
return BuildAssignment.create(plan, buildCause, builders, null, environmentVariableContext, new ArtifactStores());
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class DefaultWorkCreator method getWork.
public Work getWork(AgentIdentifier agentIdentifier) {
try {
CruiseConfig config = GoConfigMother.pipelineHavingJob(PIPELINE_NAME, STAGE_NAME, JOB_PLAN_NAME, ARTIFACT_FILE.getAbsolutePath(), ARTIFACT_FOLDER.getAbsolutePath());
BuildCause buildCause = BuildCause.createWithEmptyModifications();
BuildAssignment buildAssignment = BuildAssignment.create(toPlan(config), buildCause, new ArrayList<>(), new File("testdata/" + CruiseConfig.WORKING_BASE_DIR + STAGE_NAME), new EnvironmentVariableContext(), new ArtifactStores());
return new BuildWork(buildAssignment, "utf-8");
} catch (Exception e) {
throw bomb(e);
}
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class ArtifactsPublisherTest method shouldContinueWithOtherPluginWhenPublishArtifactCallFailsForOnePlugin.
@Test
public void shouldContinueWithOtherPluginWhenPublishArtifactCallFailsForOnePlugin() throws IOException {
final ArtifactStore s3ArtifactStore = new ArtifactStore("s3", "cd.go.s3", create("access_key", false, "some-key"));
final ArtifactStore dockerArtifactStore = new ArtifactStore("docker", "cd.go.docker", create("registry-url", false, "docker.io"));
final ArtifactStores artifactStores = new ArtifactStores(s3ArtifactStore, dockerArtifactStore);
final ArtifactPlan s3ArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
final ArtifactPlan dockerArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("test-reports", "docker", create("junit", false, "junit.xml")));
when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(s3ArtifactPlan), eq(s3ArtifactStore), anyString(), eq(env))).thenThrow(new RuntimeException("Interaction with plugin `cd.go.s3` failed."));
when(artifactExtension.publishArtifact(eq("cd.go.docker"), eq(dockerArtifactPlan), eq(dockerArtifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("tag", "10.12.0")));
try {
new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(s3ArtifactPlan, dockerArtifactPlan), env);
fail("Should throw error for pluggable artifact [installers].");
} catch (Exception e) {
assertThat(uploadedPluggableMetadataFiles(publisher.publishedFiles()), containsInAnyOrder("cd.go.docker.json"));
assertThat(publisher.getMessage(), containsString("[go] Interaction with plugin `cd.go.s3` failed"));
assertThat(e.getMessage(), containsString("[go] Uploading finished. Failed to upload [installers]."));
}
}
Aggregations