From 7ac5cc96c2a6969c2131074d0d4ba1770cab23cd Mon Sep 17 00:00:00 2001 From: Spring Buildmaster Date: Thu, 23 Jul 2020 21:53:53 +0000 Subject: [PATCH 1/7] Next development version (v2.1.17.BUILD-SNAPSHOT) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index efe6055e1a..3557f73abc 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ Spring Boot Build Spring Boot Build - 2.1.16.BUILD-SNAPSHOT + 2.1.17.BUILD-SNAPSHOT ${basedir} From c043701dc0efc2b027ff35fef748e1af2645e751 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 23 Jul 2020 17:45:49 -0700 Subject: [PATCH 2/7] Turn on debug logging --- .../releasescripts/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/releasescripts/src/main/resources/application.properties b/ci/images/releasescripts/src/main/resources/application.properties index 5bc7bb6054..873c033566 100644 --- a/ci/images/releasescripts/src/main/resources/application.properties +++ b/ci/images/releasescripts/src/main/resources/application.properties @@ -1,2 +1,2 @@ spring.main.banner-mode=off -# logging.level.io.spring.concourse=DEBUG \ No newline at end of file +logging.level.io.spring.concourse=DEBUG \ No newline at end of file From 53296cd16109dc53de867c4cb12b10cecf47bb78 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 23 Jul 2020 17:45:55 -0700 Subject: [PATCH 3/7] Backport build script updates --- ci/images/releasescripts/pom.xml | 2 +- .../concourse/releasescripts/Application.java | 4 ++- .../artifactory/ArtifactoryService.java | 2 +- .../payload/BuildInfoResponse.java | 2 +- .../bintray/BintrayService.java | 2 +- .../releasescripts/bintray/PackageFile.java | 2 +- .../command/CommandProcessor.java | 2 +- .../command/DistributeCommand.java | 2 +- .../command/PromoteCommand.java | 2 +- .../command/PublishGradlePlugin.java | 2 +- .../command/SyncToCentralCommand.java | 2 +- .../sonatype/SonatypeService.java | 2 +- .../artifactory/ArtifactoryServiceTests.java | 28 ++++++------------- .../bintray/BintrayServiceTests.java | 2 +- .../command/DistributeCommandTests.java | 2 +- .../sonatype/SonatypeServiceTests.java | 2 +- 16 files changed, 26 insertions(+), 34 deletions(-) diff --git a/ci/images/releasescripts/pom.xml b/ci/images/releasescripts/pom.xml index 95eb387726..8087d50ed3 100644 --- a/ci/images/releasescripts/pom.xml +++ b/ci/images/releasescripts/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.2.0.RELEASE + 2.2.4.RELEASE io.spring.concourse.releasescripts diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/Application.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/Application.java index 7e6495b96c..9a4c7cb9d4 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/Application.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/Application.java @@ -1,5 +1,5 @@ /* -* Copyright 2012-2019 the original author or authors. +* Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,10 @@ package io.spring.concourse.releasescripts; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; @SpringBootApplication +@ConfigurationPropertiesScan public class Application { public static void main(String[] args) { diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryService.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryService.java index 32141710ad..811eedd636 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryService.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/payload/BuildInfoResponse.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/payload/BuildInfoResponse.java index 0c340e8d04..149d2c56fd 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/payload/BuildInfoResponse.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/payload/BuildInfoResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java index b2ef96d506..80ca5fa41f 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/PackageFile.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/PackageFile.java index 4a6f3ad8cb..ee7728e812 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/PackageFile.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/PackageFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 the original author or authors. + * Copyright 2020-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/CommandProcessor.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/CommandProcessor.java index eea33a5666..50a0b2132a 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/CommandProcessor.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/CommandProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeCommand.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeCommand.java index d22aa974d3..cbd828710e 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeCommand.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PromoteCommand.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PromoteCommand.java index ef5ecc2d87..dc8f80ceba 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PromoteCommand.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PromoteCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PublishGradlePlugin.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PublishGradlePlugin.java index a00d6d340f..aa3f42c510 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PublishGradlePlugin.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PublishGradlePlugin.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/SyncToCentralCommand.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/SyncToCentralCommand.java index 0a7a02de76..e2a5cab5a8 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/SyncToCentralCommand.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/SyncToCentralCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sonatype/SonatypeService.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sonatype/SonatypeService.java index 0ef88e5639..789e4ba6a3 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sonatype/SonatypeService.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sonatype/SonatypeService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryServiceTests.java b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryServiceTests.java index 8105c8bf5e..7cf1e7f067 100644 --- a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryServiceTests.java +++ b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,9 +84,7 @@ class ArtifactoryServiceTests { @Test void promoteWhenSuccessful() { - this.server - .expect(requestTo( - "https://repo.spring.io/api/build/promote/" + "example-build" + "/" + "example-build-1")) + this.server.expect(requestTo("https://repo.spring.io/api/build/promote/example-build/example-build-1")) .andExpect(method(HttpMethod.POST)) .andExpect(content().json( "{\"status\": \"staged\", \"sourceRepo\": \"libs-staging-local\", \"targetRepo\": \"libs-milestone-local\"}")) @@ -99,11 +97,9 @@ class ArtifactoryServiceTests { @Test void promoteWhenArtifactsAlreadyPromoted() { - this.server - .expect(requestTo( - "https://repo.spring.io/api/build/promote/" + "example-build" + "/" + "example-build-1")) + this.server.expect(requestTo("https://repo.spring.io/api/build/promote/example-build/example-build-1")) .andRespond(withStatus(HttpStatus.CONFLICT)); - this.server.expect(requestTo("https://repo.spring.io/api/build/" + "example-build" + "/" + "example-build-1")) + this.server.expect(requestTo("https://repo.spring.io/api/build/example-build/example-build-1")) .andRespond(withJsonFrom("build-info-response.json")); this.service.promote("libs-release-local", getReleaseInfo()); this.server.verify(); @@ -111,11 +107,9 @@ class ArtifactoryServiceTests { @Test void promoteWhenCheckForArtifactsAlreadyPromotedFails() { - this.server - .expect(requestTo( - "https://repo.spring.io/api/build/promote/" + "example-build" + "/" + "example-build-1")) + this.server.expect(requestTo("https://repo.spring.io/api/build/promote/example-build/example-build-1")) .andRespond(withStatus(HttpStatus.CONFLICT)); - this.server.expect(requestTo("https://repo.spring.io/api/build/" + "example-build" + "/" + "example-build-1")) + this.server.expect(requestTo("https://repo.spring.io/api/build/example-build/example-build-1")) .andRespond(withStatus(HttpStatus.FORBIDDEN)); assertThatExceptionOfType(HttpClientErrorException.class) .isThrownBy(() -> this.service.promote("libs-release-local", getReleaseInfo())); @@ -124,11 +118,9 @@ class ArtifactoryServiceTests { @Test void promoteWhenPromotionFails() { - this.server - .expect(requestTo( - "https://repo.spring.io/api/build/promote/" + "example-build" + "/" + "example-build-1")) + this.server.expect(requestTo("https://repo.spring.io/api/build/promote/example-build/example-build-1")) .andRespond(withStatus(HttpStatus.CONFLICT)); - this.server.expect(requestTo("https://repo.spring.io/api/build/" + "example-build" + "/" + "example-build-1")) + this.server.expect(requestTo("https://repo.spring.io/api/build/example-build/example-build-1")) .andRespond(withJsonFrom("staged-build-info-response.json")); assertThatExceptionOfType(HttpClientErrorException.class) .isThrownBy(() -> this.service.promote("libs-release-local", getReleaseInfo())); @@ -158,9 +150,7 @@ class ArtifactoryServiceTests { @Test void distributeWhenFailure() throws Exception { ReleaseInfo releaseInfo = getReleaseInfo(); - this.server - .expect(requestTo( - "https://repo.spring.io/api/build/distribute/" + "example-build" + "/" + "example-build-1")) + this.server.expect(requestTo("https://repo.spring.io/api/build/distribute/example-build/example-build-1")) .andExpect(method(HttpMethod.POST)) .andExpect(content().json( "{\"sourceRepos\": [\"libs-release-local\"], \"targetRepo\" : \"spring-distributions\", \"async\":\"true\"}")) diff --git a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/bintray/BintrayServiceTests.java b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/bintray/BintrayServiceTests.java index 67c4369c8e..e88780cf2c 100644 --- a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/bintray/BintrayServiceTests.java +++ b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/bintray/BintrayServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/DistributeCommandTests.java b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/DistributeCommandTests.java index 3fcaf5dc7e..ef949b0ada 100644 --- a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/DistributeCommandTests.java +++ b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/DistributeCommandTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sonatype/SonatypeServiceTests.java b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sonatype/SonatypeServiceTests.java index ae0a257ecd..d8e09f70e1 100644 --- a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sonatype/SonatypeServiceTests.java +++ b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sonatype/SonatypeServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From d69c35a1db2faf4bd534b70c19ea017205e28e59 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 23 Jul 2020 18:23:24 -0700 Subject: [PATCH 4/7] Deal with 404 response when checking for artifacts --- .../concourse/releasescripts/bintray/BintrayService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java index 80ca5fa41f..7a224f3262 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java @@ -101,8 +101,13 @@ public class BintrayService { try { waitAtMost(timeout).with().pollDelay(Duration.ZERO).pollInterval(pollInterval).until(() -> { logger.debug("Checking bintray"); - PackageFile[] published = this.restTemplate.exchange(request, PackageFile[].class).getBody(); - return hasPublishedAll(published, requiredDigests); + try { + PackageFile[] published = this.restTemplate.exchange(request, PackageFile[].class).getBody(); + return hasPublishedAll(published, requiredDigests); + } + catch (HttpClientErrorException.NotFound ex) { + return false; + } }); } catch (ConditionTimeoutException ex) { From b77dbcd06fa09b1af25f96899644ef5ac9d0a082 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 23 Jul 2020 20:45:25 -0700 Subject: [PATCH 5/7] Allow certain artifacts to be optionally deployed Update `DistributeCommand` so that regex patterns can be used to mark artifacts that are optional and need not fail the release. Closes gh-22543 --- .../command/DistributeCommand.java | 22 ++++++- .../command/DistributeProperties.java | 42 +++++++++++++ .../command/DistributeCommandTests.java | 30 +++++++++- .../src/test/resources/application.yml | 4 ++ .../filtered-build-info-response.json | 59 +++++++++++++++++++ 5 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeProperties.java create mode 100644 ci/images/releasescripts/src/test/resources/io/spring/concourse/releasescripts/artifactory/filtered-build-info-response.json diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeCommand.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeCommand.java index cbd828710e..f8f8ea11a1 100644 --- a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeCommand.java +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeCommand.java @@ -20,6 +20,8 @@ import java.io.File; import java.nio.file.Files; import java.util.List; import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Collectors; import com.fasterxml.jackson.databind.ObjectMapper; import io.spring.concourse.releasescripts.ReleaseInfo; @@ -40,6 +42,7 @@ import org.springframework.util.Assert; * Command used to deploy builds from Artifactory to Bintray. * * @author Madhura Bhave + * @author Phillip Webb */ @Component public class DistributeCommand implements Command { @@ -50,9 +53,14 @@ public class DistributeCommand implements Command { private final ObjectMapper objectMapper; - public DistributeCommand(ArtifactoryService artifactoryService, ObjectMapper objectMapper) { + private final List optionalDeployments; + + public DistributeCommand(ArtifactoryService artifactoryService, ObjectMapper objectMapper, + DistributeProperties distributeProperties) { this.artifactoryService = artifactoryService; this.objectMapper = objectMapper; + this.optionalDeployments = distributeProperties.getOptionalDeployments().stream().map(Pattern::compile) + .collect(Collectors.toList()); } @Override @@ -80,8 +88,18 @@ public class DistributeCommand implements Command { } } ReleaseInfo releaseInfo = ReleaseInfo.from(buildInfo); - Set artifactDigests = buildInfo.getArtifactDigests((artifact) -> !artifact.getName().endsWith(".zip")); + Set artifactDigests = buildInfo.getArtifactDigests(this::isIncluded); this.artifactoryService.distribute(type.getRepo(), releaseInfo, artifactDigests); } + private boolean isIncluded(Artifact artifact) { + String path = artifact.getName(); + for (Pattern optionalDeployment : this.optionalDeployments) { + if (optionalDeployment.matcher(path).matches()) { + return false; + } + } + return true; + } + } diff --git a/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeProperties.java b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeProperties.java new file mode 100644 index 0000000000..6e56b0763a --- /dev/null +++ b/ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeProperties.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.spring.concourse.releasescripts.command; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Distribution properties. + * + * @author Phillip Webb + */ +@ConfigurationProperties(prefix = "distribute") +public class DistributeProperties { + + private List optionalDeployments = new ArrayList<>(); + + public List getOptionalDeployments() { + return this.optionalDeployments; + } + + public void setOptionalDeployments(List optionalDeployments) { + this.optionalDeployments = optionalDeployments; + } + +} diff --git a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/DistributeCommandTests.java b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/DistributeCommandTests.java index ef949b0ada..080c10013a 100644 --- a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/DistributeCommandTests.java +++ b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/command/DistributeCommandTests.java @@ -16,6 +16,7 @@ package io.spring.concourse.releasescripts.command; +import java.util.Arrays; import java.util.Set; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -42,6 +43,7 @@ import static org.mockito.Mockito.verifyNoInteractions; * Tests for {@link DistributeCommand}. * * @author Madhura Bhave + * @author Phillip Webb */ class DistributeCommandTests { @@ -55,8 +57,10 @@ class DistributeCommandTests { @BeforeEach void setup() { MockitoAnnotations.initMocks(this); + DistributeProperties distributeProperties = new DistributeProperties(); + distributeProperties.setOptionalDeployments(Arrays.asList(".*\\.zip", "demo-\\d\\.\\d\\.\\d\\.doc")); this.objectMapper = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - this.command = new DistributeCommand(this.service, this.objectMapper); + this.command = new DistributeCommand(this.service, this.objectMapper, distributeProperties); } @Test @@ -94,8 +98,30 @@ class DistributeCommandTests { assertThat(artifactDigests).containsExactly("aaaaaaaaa85f5c5093721f3ed0edda8ff8290yyyyyyyyyy"); } + @Test + @SuppressWarnings("unchecked") + void distributeWhenReleaseTypeReleaseAndFilteredShouldCallService() throws Exception { + ArgumentCaptor releaseInfoCaptor = ArgumentCaptor.forClass(ReleaseInfo.class); + ArgumentCaptor> artifactDigestCaptor = ArgumentCaptor.forClass(Set.class); + this.command.run(new DefaultApplicationArguments("distribute", "RELEASE", + getBuildInfoLocation("filtered-build-info-response.json"))); + verify(this.service).distribute(eq(ReleaseType.RELEASE.getRepo()), releaseInfoCaptor.capture(), + artifactDigestCaptor.capture()); + ReleaseInfo releaseInfo = releaseInfoCaptor.getValue(); + assertThat(releaseInfo.getBuildName()).isEqualTo("example"); + assertThat(releaseInfo.getBuildNumber()).isEqualTo("example-build-1"); + assertThat(releaseInfo.getGroupId()).isEqualTo("org.example.demo"); + assertThat(releaseInfo.getVersion()).isEqualTo("2.2.0"); + Set artifactDigests = artifactDigestCaptor.getValue(); + assertThat(artifactDigests).containsExactly("aaaaaaaaa85f5c5093721f3ed0edda8ff8290yyyyyyyyyy"); + } + private String getBuildInfoLocation() throws Exception { - return new ClassPathResource("build-info-response.json", ArtifactoryService.class).getFile().getAbsolutePath(); + return getBuildInfoLocation("build-info-response.json"); + } + + private String getBuildInfoLocation(String file) throws Exception { + return new ClassPathResource(file, ArtifactoryService.class).getFile().getAbsolutePath(); } } \ No newline at end of file diff --git a/ci/images/releasescripts/src/test/resources/application.yml b/ci/images/releasescripts/src/test/resources/application.yml index 88fe8a8f34..11208bfa69 100644 --- a/ci/images/releasescripts/src/test/resources/application.yml +++ b/ci/images/releasescripts/src/test/resources/application.yml @@ -9,3 +9,7 @@ bintray: sonatype: user-token: sonatype-user password-token: sonatype-password +distribute: + optional-deployments: + - '.*\.zip' + - 'spring-boot-project-\d\.\d\.\d(?:\.RELEASE)?\.pom' diff --git a/ci/images/releasescripts/src/test/resources/io/spring/concourse/releasescripts/artifactory/filtered-build-info-response.json b/ci/images/releasescripts/src/test/resources/io/spring/concourse/releasescripts/artifactory/filtered-build-info-response.json new file mode 100644 index 0000000000..9f9935114d --- /dev/null +++ b/ci/images/releasescripts/src/test/resources/io/spring/concourse/releasescripts/artifactory/filtered-build-info-response.json @@ -0,0 +1,59 @@ +{ + "buildInfo": { + "version": "1.0.1", + "name": "example", + "number": "example-build-1", + "started": "2019-09-10T12:18:05.430+0000", + "durationMillis": 0, + "artifactoryPrincipal": "user", + "url": "https://my-ci.com", + "modules": [ + { + "id": "org.example.demo:demo:2.2.0", + "artifacts": [ + { + "type": "jar", + "sha1": "ayyyya9151a22cb3145538e523dbbaaaaaaaa", + "sha256": "aaaaaaaaa85f5c5093721f3ed0edda8ff8290yyyyyyyyyy", + "md5": "aaaaaacddea1724b0b69d8yyyyyyy", + "name": "demo-2.2.0.jar" + } + ] + }, + { + "id": "org.example.demo:demo:2.2.0:zip", + "artifacts": [ + { + "type": "zip", + "sha1": "ayyyya9151a22cb3145538e523dbbaaaaaaab", + "sha256": "aaaaaaaaa85f5c5093721f3ed0edda8ff8290yyyyyyyyyz", + "md5": "aaaaaacddea1724b0b69d8yyyyyyz", + "name": "demo-2.2.0.zip" + } + ] + }, + { + "id": "org.example.demo:demo:2.2.0:doc", + "artifacts": [ + { + "type": "jar", + "sha1": "ayyyya9151a22cb3145538e523dbbaaaaaaba", + "sha256": "aaaaaaaaa85f5c5093721f3ed0edda8ff8290yyyyyyyyzy", + "md5": "aaaaaacddea1724b0b69d8yyyyyzy", + "name": "demo-2.2.0.doc" + } + ] + } + ], + "statuses": [ + { + "status": "staged", + "repository": "libs-release-local", + "timestamp": "2019-09-10T12:42:24.716+0000", + "user": "user", + "timestampDate": 1568119344716 + } + ] + }, + "uri": "https://my-artifactory-repo.com/api/build/example/example-build-1" +} \ No newline at end of file From 7ace6cd450b7dd36004357be9e21e57e2b5a0d6c Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 23 Jul 2020 21:09:15 -0700 Subject: [PATCH 6/7] Move properties to correct file See gh-22543 --- .../releasescripts/src/main/resources/application.properties | 2 ++ ci/images/releasescripts/src/test/resources/application.yml | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/images/releasescripts/src/main/resources/application.properties b/ci/images/releasescripts/src/main/resources/application.properties index 873c033566..a3af09f0dd 100644 --- a/ci/images/releasescripts/src/main/resources/application.properties +++ b/ci/images/releasescripts/src/main/resources/application.properties @@ -1,2 +1,4 @@ spring.main.banner-mode=off +distribute.optional-deployments[0]=.*\\.zip +distribute.optional-deployments[1]=spring-boot-project-\\d\\.\\d\\.\\d(?:\\.RELEASE)?\\.pom logging.level.io.spring.concourse=DEBUG \ No newline at end of file diff --git a/ci/images/releasescripts/src/test/resources/application.yml b/ci/images/releasescripts/src/test/resources/application.yml index 11208bfa69..88fe8a8f34 100644 --- a/ci/images/releasescripts/src/test/resources/application.yml +++ b/ci/images/releasescripts/src/test/resources/application.yml @@ -9,7 +9,3 @@ bintray: sonatype: user-token: sonatype-user password-token: sonatype-password -distribute: - optional-deployments: - - '.*\.zip' - - 'spring-boot-project-\d\.\d\.\d(?:\.RELEASE)?\.pom' From f68671e1bcfafcf21b2a1fc462b234948889bb2f Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 23 Jul 2020 21:23:42 -0700 Subject: [PATCH 7/7] Refine regex See gh-22543 --- .../releasescripts/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images/releasescripts/src/main/resources/application.properties b/ci/images/releasescripts/src/main/resources/application.properties index a3af09f0dd..44dc307221 100644 --- a/ci/images/releasescripts/src/main/resources/application.properties +++ b/ci/images/releasescripts/src/main/resources/application.properties @@ -1,4 +1,4 @@ spring.main.banner-mode=off distribute.optional-deployments[0]=.*\\.zip -distribute.optional-deployments[1]=spring-boot-project-\\d\\.\\d\\.\\d(?:\\.RELEASE)?\\.pom +distribute.optional-deployments[1]=spring-boot-project-\\d+\\.\\d+\\.\\d+(?:\\.RELEASE)?\\.pom logging.level.io.spring.concourse=DEBUG \ No newline at end of file