@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 shouldCallArtifactExtensionWithMetadata() throws IOException {
        final FetchPluggableArtifactBuilder builder = new FetchPluggableArtifactBuilder(new RunIfConfigs(), new NullBuilder(), "", jobIdentifier, artifactStore, fetchPluggableArtifactTask.getConfiguration(), fetchPluggableArtifactTask.getArtifactId(), sourceOnServer, metadataDest.toFile(), checksumFileHandler);
        final Map<String, Object> metadata = Map.of("Version", "10.12.0");

         Files.writeString(metadataDest, new Gson().toJson(Map.of("artifactId", metadata)), UTF_8);

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

        verify(artifactExtension).fetchArtifact(eq(PLUGIN_ID), eq(artifactStore), eq(fetchPluggableArtifactTask.getConfiguration()), eq(metadata), eq(metadataDest.getParent().toString()));
    }