Search in sources :

Example 1 with ArtifactStores

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"));
}
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 2 with ArtifactStores

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

Example 3 with ArtifactStores

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());
}
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) NullBuilder(com.thoughtworks.go.domain.builder.NullBuilder) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder)

Example 4 with 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);
    }
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) BuildWork(com.thoughtworks.go.remote.work.BuildWork) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) IOException(java.io.IOException) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 5 with ArtifactStores

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]."));
    }
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) PublishArtifactResponse(com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

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