Skip to content

Commit

Permalink
Merge branch '2.5.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Jun 25, 2021
2 parents d00db60 + 0c99bc8 commit 5e6bed2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import io.spring.concourse.releasescripts.ReleaseInfo;
import io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse;
import io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse.Status;
import io.spring.concourse.releasescripts.artifactory.payload.PromotionRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -96,7 +97,12 @@ private boolean isAlreadyPromoted(String buildName, String buildNumber, String t
logger.debug("Checking if already promoted");
ResponseEntity<BuildInfoResponse> entity = this.restTemplate
.getForEntity(BUILD_INFO_URL + buildName + "/" + buildNumber, BuildInfoResponse.class);
BuildInfoResponse.Status status = entity.getBody().getBuildInfo().getStatuses()[0];
Status[] statuses = entity.getBody().getBuildInfo().getStatuses();
BuildInfoResponse.Status status = (statuses != null) ? statuses[0] : null;
if (status == null) {
logger.debug("Returned no status object");
return false;
}
logger.debug("Returned repository " + status.getRepository() + " expecting " + targetRepo);
return status.getRepository().equals(targetRepo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ void promoteWhenCheckForArtifactsAlreadyPromotedFails() {
this.server.verify();
}

@Test
void promoteWhenCheckForArtifactsAlreadyPromotedReturnsNoStatus() {
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"))
.andRespond(withJsonFrom("no-status-build-info-response.json"));
assertThatExceptionOfType(HttpClientErrorException.class)
.isThrownBy(() -> this.service.promote("libs-milestone-local", getReleaseInfo()));
this.server.verify();
}

@Test
void promoteWhenPromotionFails() {
this.server.expect(requestTo("https://repo.spring.io/api/build/promote/example-build/example-build-1"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"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"
}
]
}
]
},
"uri": "https://my-artifactory-repo.com/api/build/example/example-build-1"
}

0 comments on commit 5e6bed2

Please sign in to comment.