|
17 | 17 | package io.spring.concourse.releasescripts.artifactory;
|
18 | 18 |
|
19 | 19 | import java.net.URI;
|
20 |
| -import java.time.Duration; |
21 |
| -import java.util.Set; |
22 | 20 |
|
23 | 21 | import io.spring.concourse.releasescripts.ReleaseInfo;
|
24 | 22 | import io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse;
|
25 |
| -import io.spring.concourse.releasescripts.artifactory.payload.DistributionRequest; |
26 | 23 | import io.spring.concourse.releasescripts.artifactory.payload.PromotionRequest;
|
27 |
| -import io.spring.concourse.releasescripts.bintray.BintrayService; |
28 | 24 | import org.slf4j.Logger;
|
29 | 25 | import org.slf4j.LoggerFactory;
|
30 | 26 |
|
@@ -53,17 +49,11 @@ public class ArtifactoryService {
|
53 | 49 |
|
54 | 50 | private static final String BUILD_INFO_URL = ARTIFACTORY_URL + "/api/build/";
|
55 | 51 |
|
56 |
| - private static final String DISTRIBUTION_URL = ARTIFACTORY_URL + "/api/build/distribute/"; |
57 |
| - |
58 | 52 | private static final String STAGING_REPO = "libs-staging-local";
|
59 | 53 |
|
60 | 54 | private final RestTemplate restTemplate;
|
61 | 55 |
|
62 |
| - private final BintrayService bintrayService; |
63 |
| - |
64 |
| - public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties, |
65 |
| - BintrayService bintrayService) { |
66 |
| - this.bintrayService = bintrayService; |
| 56 | + public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties) { |
67 | 57 | String username = artifactoryProperties.getUsername();
|
68 | 58 | String password = artifactoryProperties.getPassword();
|
69 | 59 | if (StringUtils.hasLength(username)) {
|
@@ -116,37 +106,6 @@ private boolean isAlreadyPromoted(String buildName, String buildNumber, String t
|
116 | 106 | }
|
117 | 107 | }
|
118 | 108 |
|
119 |
| - /** |
120 |
| - * Deploy builds from Artifactory to Bintray. |
121 |
| - * @param sourceRepo the source repo in Artifactory. |
122 |
| - * @param releaseInfo the resease info |
123 |
| - * @param artifactDigests the artifact digests |
124 |
| - */ |
125 |
| - public void distribute(String sourceRepo, ReleaseInfo releaseInfo, Set<String> artifactDigests) { |
126 |
| - logger.debug("Attempting distribute via Artifactory"); |
127 |
| - if (!this.bintrayService.isDistributionStarted(releaseInfo)) { |
128 |
| - startDistribute(sourceRepo, releaseInfo); |
129 |
| - } |
130 |
| - if (!this.bintrayService.isDistributionComplete(releaseInfo, artifactDigests, Duration.ofMinutes(60))) { |
131 |
| - throw new DistributionTimeoutException("Distribution timed out."); |
132 |
| - } |
133 |
| - } |
134 |
| - |
135 |
| - private void startDistribute(String sourceRepo, ReleaseInfo releaseInfo) { |
136 |
| - DistributionRequest request = new DistributionRequest(new String[] { sourceRepo }); |
137 |
| - RequestEntity<DistributionRequest> requestEntity = RequestEntity |
138 |
| - .post(URI.create(DISTRIBUTION_URL + releaseInfo.getBuildName() + "/" + releaseInfo.getBuildNumber())) |
139 |
| - .contentType(MediaType.APPLICATION_JSON).body(request); |
140 |
| - try { |
141 |
| - this.restTemplate.exchange(requestEntity, Object.class); |
142 |
| - logger.debug("Distribute call completed"); |
143 |
| - } |
144 |
| - catch (HttpClientErrorException ex) { |
145 |
| - logger.info("Failed to distribute."); |
146 |
| - throw ex; |
147 |
| - } |
148 |
| - } |
149 |
| - |
150 | 109 | private PromotionRequest getPromotionRequest(String targetRepo) {
|
151 | 110 | return new PromotionRequest("staged", STAGING_REPO, targetRepo);
|
152 | 111 | }
|
|
0 commit comments