@Override
    public void build(DefaultGoPublisher publisher, EnvironmentVariableContext environmentVariableContext, TaskExtension taskExtension, ArtifactExtension artifactExtension, PluginRequestProcessorRegistry pluginRequestProcessorRegistry, Charset consoleLogCharset) {
        downloadMetadataFile(publisher);
        try {
            pluginRequestProcessorRegistry.registerProcessorFor(CONSOLE_LOG.requestName(), ArtifactRequestProcessor.forFetchArtifact(publisher, environmentVariableContext));
            final String message = format("[%s] Fetching pluggable artifact using plugin `%s`.", GoConstants.PRODUCT_NAME, artifactStore.getPluginId());
            LOGGER.info(message);
            publisher.taggedConsumeLine(TaggedStreamConsumer.OUT, message);

            List<FetchArtifactEnvironmentVariable> newEnvironmentVariables = artifactExtension.fetchArtifact(
                    artifactStore.getPluginId(), artifactStore, configuration, getMetadataFromFile(artifactId), agentWorkingDirectory());

            updateEnvironmentVariableContextWith(publisher, environmentVariableContext, newEnvironmentVariables);

        } catch (Exception e) {
            publisher.taggedConsumeLine(TaggedStreamConsumer.ERR, e.getMessage());
            LOGGER.error(e.getMessage(), e);
            throw new RuntimeException(e);
        } finally {
            pluginRequestProcessorRegistry.removeProcessorFor(CONSOLE_LOG.requestName());
        }
    }
@Test
    public void shouldCallPublisherToFetchMetadataFile() {
        final FetchPluggableArtifactBuilder builder = new FetchPluggableArtifactBuilder(new RunIfConfigs(), new NullBuilder(), "", jobIdentifier, artifactStore, fetchPluggableArtifactTask.getConfiguration(), fetchPluggableArtifactTask.getArtifactId(), sourceOnServer, metadataDest.toFile(), checksumFileHandler);

        builder.build(publisher, new EnvironmentVariableContext(), null, artifactExtension, registry, UTF_8);

        final ArgumentCaptor<FetchArtifactBuilder> argumentCaptor = ArgumentCaptor.forClass(FetchArtifactBuilder.class);

        verify(publisher).fetch(argumentCaptor.capture());

        final FetchArtifactBuilder fetchArtifactBuilder = argumentCaptor.getValue();

        assertThat(fetchArtifactBuilder.getSrc(), is("pluggable-artifact-metadata/cd.go.s3.json"));
        assertThat(fetchArtifactBuilder.getDest(), is("cd.go.s3.json"));
    }