Search in sources :

Example 1 with ArtifactRequestProcessor

use of com.thoughtworks.go.remote.work.artifact.ArtifactRequestProcessor in project gocd by gocd.

the class FetchPluggableArtifactBuilder method build.

@Override
public void build(DefaultGoPublisher publisher, EnvironmentVariableContext environmentVariableContext, TaskExtension taskExtension, ArtifactExtension artifactExtension, PluginRequestProcessorRegistry pluginRequestProcessorRegistry, String consoleLogCharset) {
    downloadMetadataFile(publisher);
    try {
        pluginRequestProcessorRegistry.registerProcessorFor(CONSOLE_LOG.requestName(), new ArtifactRequestProcessor(publisher));
        final String message = format("[%s] Fetching pluggable artifact using plugin %s.", GoConstants.PRODUCT_NAME, artifactStore.getPluginId());
        LOGGER.info(message);
        publisher.taggedConsumeLine(TaggedStreamConsumer.OUT, message);
        artifactExtension.fetchArtifact(artifactStore.getPluginId(), artifactStore, configuration, getMetadataFromFile(artifactId), agentWorkingDirectory());
    } catch (Exception e) {
        publisher.taggedConsumeLine(TaggedStreamConsumer.ERR, e.getMessage());
        LOGGER.error(e.getMessage(), e);
        throw new RuntimeException(e);
    } finally {
        pluginRequestProcessorRegistry.removeProcessorFor(CONSOLE_LOG.requestName());
    }
}
Also used : ArtifactRequestProcessor(com.thoughtworks.go.remote.work.artifact.ArtifactRequestProcessor) IOException(java.io.IOException)

Example 2 with ArtifactRequestProcessor

use of com.thoughtworks.go.remote.work.artifact.ArtifactRequestProcessor in project gocd by gocd.

the class ArtifactRequestProcessorTest method setUp.

@Before
public void setUp() throws Exception {
    request = mock(GoApiRequest.class);
    descriptor = mock(GoPluginDescriptor.class);
    goPublisher = mock(DefaultGoPublisher.class);
    artifactRequestProcessor = new ArtifactRequestProcessor(goPublisher);
    when(request.apiVersion()).thenReturn("1.0");
    when(descriptor.id()).thenReturn("cd.go.artifact.docker");
    when(request.api()).thenReturn(CONSOLE_LOG.requestName());
}
Also used : DefaultGoPublisher(com.thoughtworks.go.work.DefaultGoPublisher) GoApiRequest(com.thoughtworks.go.plugin.api.request.GoApiRequest) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ArtifactRequestProcessor(com.thoughtworks.go.remote.work.artifact.ArtifactRequestProcessor) Before(org.junit.Before)

Aggregations

ArtifactRequestProcessor (com.thoughtworks.go.remote.work.artifact.ArtifactRequestProcessor)2 GoApiRequest (com.thoughtworks.go.plugin.api.request.GoApiRequest)1 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)1 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)1 IOException (java.io.IOException)1 Before (org.junit.Before)1