Search in sources :

Example 16 with ArtifactStores

use of com.thoughtworks.go.config.ArtifactStores 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<>(), -1, new JobIdentifier(PIPELINE_NAME, 1, "1", STAGE_NAME, "1", JOB_NAME, 123L), null, new EnvironmentVariables(), new EnvironmentVariables(), null, 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)

Example 17 with ArtifactStores

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

the class ArtifactsPublisherTest method shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact.

@Test
public void shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact() {
    final ArtifactStore s3ArtifactStore = new ArtifactStore("s3", "cd.go.s3", create("access_key", false, "some-key"));
    final ArtifactStores artifactStores = new ArtifactStores(s3ArtifactStore);
    final ArtifactPlan s3ArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(s3ArtifactPlan), eq(s3ArtifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("src", "s3://dist")));
    new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(s3ArtifactPlan), env);
    InOrder inOrder = inOrder(registry, artifactExtension);
    inOrder.verify(registry, times(1)).registerProcessorFor(eq(CONSOLE_LOG.requestName()), any(ArtifactRequestProcessor.class));
    inOrder.verify(artifactExtension, times(1)).publishArtifact("cd.go.s3", s3ArtifactPlan, s3ArtifactStore, workingFolder.getAbsolutePath(), env);
    inOrder.verify(registry, times(1)).removeProcessorFor(CONSOLE_LOG.requestName());
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) InOrder(org.mockito.InOrder) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) PublishArtifactResponse(com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse) Test(org.junit.jupiter.api.Test)

Example 18 with ArtifactStores

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

the class ArtifactsPublisherTest method shouldNotUploadMetadataFileWhenPublishPluggableArtifactIsUnsuccessful.

@Test
public void shouldNotUploadMetadataFileWhenPublishPluggableArtifactIsUnsuccessful() {
    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")));
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenThrow(new RuntimeException("something"));
    try {
        new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(artifactPlan), env);
        fail("Should throw error for pluggable artifact [installers].");
    } catch (Exception e) {
        assertThat(publisher.publishedFiles().size(), is(0));
        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) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 19 with ArtifactStores

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

the class ArtifactsPublisherTest method setUp.

@BeforeEach
public void setUp() throws IOException {
    artifactExtension = mock(ArtifactExtension.class);
    registry = mock(PluginRequestProcessorRegistry.class);
    publisher = new StubGoPublisher();
    artifactsPublisher = new ArtifactsPublisher(publisher, artifactExtension, new ArtifactStores(), registry, workingFolder);
    File file = new File(workingFolder, "cruise-output/log.xml");
    file.getParentFile().mkdirs();
    file.createNewFile();
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) ArtifactExtension(com.thoughtworks.go.plugin.access.artifact.ArtifactExtension) PluginRequestProcessorRegistry(com.thoughtworks.go.plugin.infra.PluginRequestProcessorRegistry) File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 20 with ArtifactStores

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

the class ArtifactsPublisherTest method shouldErrorOutWhenFailedToCreateFolderToWritePluggableArtifactMetadata.

@Test
public void shouldErrorOutWhenFailedToCreateFolderToWritePluggableArtifactMetadata() {
    Assumptions.assumeFalse(IS_WINDOWS, "Do not run on windows.");
    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")));
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
    workingFolder.setWritable(false);
    assertThatThrownBy(() -> new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(artifactPlan), env)).isInstanceOf(RuntimeException.class).hasMessageContaining("[go] Could not create pluggable artifact metadata folder");
}
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) 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