public void publishArtifacts(List<ArtifactPlan> artifactPlans, EnvironmentVariableContext environmentVariableContext) {
        final File pluggableArtifactFolder = publishPluggableArtifacts(artifactPlans, environmentVariableContext);
        try {
            final List<ArtifactPlan> mergedPlans = artifactPlanFilter.getBuiltInMergedArtifactPlans(artifactPlans);

            if (isMetadataFolderEmpty(pluggableArtifactFolder)) {
                LOGGER.info("Pluggable metadata folder is empty.");
            } else if (pluggableArtifactFolder != null) {
                mergedPlans.add(0, new ArtifactPlan(ArtifactPlanType.file, format("%s%s*", pluggableArtifactFolder.getName(), File.separator), PLUGGABLE_ARTIFACT_METADATA_FOLDER));
            }

            for (ArtifactPlan artifactPlan : mergedPlans) {
                try {
                    artifactPlan.publishBuiltInArtifacts(goPublisher, workingDirectory);
                } catch (Exception e) {
                    failedArtifact.add(artifactPlan);
                }
            }

            if (!failedArtifact.isEmpty()) {
                StringBuilder builder = new StringBuilder();
                for (ArtifactPlan artifactPlan : failedArtifact) {
                    artifactPlan.printArtifactInfo(builder);
                }
                throw new RuntimeException(format("[%s] Uploading finished. Failed to upload %s.", PRODUCT_NAME, builder));
            }
        } finally {
            FileUtils.deleteQuietly(pluggableArtifactFolder);
        }
    }
@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"));

        assertThatThrownBy(() -> new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder)
                    .publishArtifacts(List.of(artifactPlan), env))
            .hasMessageContaining("[go] Uploading finished. Failed to upload [installers].");
        assertThat(publisher.publishedFiles().size()).isEqualTo(0);
    }