Skip to content

Commit

Permalink
Merge branch '2.3.x' into 2.4.x
Browse files Browse the repository at this point in the history
Closes gh-25343
  • Loading branch information
wilkinsona committed Feb 17, 2021
2 parents 5d1bb30 + 98ee724 commit dea9b7f
Show file tree
Hide file tree
Showing 184 changed files with 2,320 additions and 1,502 deletions.
5 changes: 5 additions & 0 deletions ci/images/releasescripts/pom.xml
Expand Up @@ -19,6 +19,11 @@
<spring-javaformat.version>0.0.26</spring-javaformat.version>
</properties>
<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk15to18</artifactId>
<version>1.68</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand Down
Expand Up @@ -17,14 +17,10 @@
package io.spring.concourse.releasescripts.artifactory;

import java.net.URI;
import java.time.Duration;
import java.util.Set;

import io.spring.concourse.releasescripts.ReleaseInfo;
import io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse;
import io.spring.concourse.releasescripts.artifactory.payload.DistributionRequest;
import io.spring.concourse.releasescripts.artifactory.payload.PromotionRequest;
import io.spring.concourse.releasescripts.bintray.BintrayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -53,17 +49,11 @@ public class ArtifactoryService {

private static final String BUILD_INFO_URL = ARTIFACTORY_URL + "/api/build/";

private static final String DISTRIBUTION_URL = ARTIFACTORY_URL + "/api/build/distribute/";

private static final String STAGING_REPO = "libs-staging-local";

private final RestTemplate restTemplate;

private final BintrayService bintrayService;

public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties,
BintrayService bintrayService) {
this.bintrayService = bintrayService;
public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties) {
String username = artifactoryProperties.getUsername();
String password = artifactoryProperties.getPassword();
if (StringUtils.hasLength(username)) {
Expand Down Expand Up @@ -116,37 +106,6 @@ private boolean isAlreadyPromoted(String buildName, String buildNumber, String t
}
}

/**
* Deploy builds from Artifactory to Bintray.
* @param sourceRepo the source repo in Artifactory.
* @param releaseInfo the resease info
* @param artifactDigests the artifact digests
*/
public void distribute(String sourceRepo, ReleaseInfo releaseInfo, Set<String> artifactDigests) {
logger.debug("Attempting distribute via Artifactory");
if (!this.bintrayService.isDistributionStarted(releaseInfo)) {
startDistribute(sourceRepo, releaseInfo);
}
if (!this.bintrayService.isDistributionComplete(releaseInfo, artifactDigests, Duration.ofMinutes(60))) {
throw new DistributionTimeoutException("Distribution timed out.");
}
}

private void startDistribute(String sourceRepo, ReleaseInfo releaseInfo) {
DistributionRequest request = new DistributionRequest(new String[] { sourceRepo });
RequestEntity<DistributionRequest> requestEntity = RequestEntity
.post(URI.create(DISTRIBUTION_URL + releaseInfo.getBuildName() + "/" + releaseInfo.getBuildNumber()))
.contentType(MediaType.APPLICATION_JSON).body(request);
try {
this.restTemplate.exchange(requestEntity, Object.class);
logger.debug("Distribute call completed");
}
catch (HttpClientErrorException ex) {
logger.info("Failed to distribute.");
throw ex;
}
}

private PromotionRequest getPromotionRequest(String targetRepo) {
return new PromotionRequest("staged", STAGING_REPO, targetRepo);
}
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit dea9b7f

Please sign in to comment.