use of io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse in project spring-boot by spring-projects.
the class PublishToCentralCommand method run.
@Override
public void run(ApplicationArguments args) throws Exception {
List<String> nonOptionArgs = args.getNonOptionArgs();
Assert.state(nonOptionArgs.size() == 4, "Release type, build info location, or artifacts location not specified");
String releaseType = nonOptionArgs.get(1);
ReleaseType type = ReleaseType.from(releaseType);
if (!ReleaseType.RELEASE.equals(type)) {
return;
}
String buildInfoLocation = nonOptionArgs.get(2);
logger.debug("Loading build-info from " + buildInfoLocation);
byte[] content = Files.readAllBytes(new File(buildInfoLocation).toPath());
BuildInfoResponse buildInfoResponse = this.objectMapper.readValue(content, BuildInfoResponse.class);
BuildInfo buildInfo = buildInfoResponse.getBuildInfo();
ReleaseInfo releaseInfo = ReleaseInfo.from(buildInfo);
String artifactsLocation = nonOptionArgs.get(3);
this.sonatype.publish(releaseInfo, new File(artifactsLocation).toPath());
}
use of io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse in project spring-boot by spring-projects.
the class ArtifactoryService method isAlreadyPromoted.
private boolean isAlreadyPromoted(String buildName, String buildNumber, String targetRepo) {
try {
logger.debug("Checking if already promoted");
ResponseEntity<BuildInfoResponse> entity = this.restTemplate.getForEntity(BUILD_INFO_URL + buildName + "/" + buildNumber, BuildInfoResponse.class);
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);
} catch (HttpClientErrorException ex) {
logger.debug("Client error, assuming not promoted");
return false;
}
}
use of io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse in project spring-boot by spring-projects.
the class PromoteCommand method run.
@Override
public void run(ApplicationArguments args) throws Exception {
logger.debug("Running 'promote' command");
List<String> nonOptionArgs = args.getNonOptionArgs();
Assert.state(!nonOptionArgs.isEmpty(), "No command argument specified");
Assert.state(nonOptionArgs.size() == 3, "Release type or build info location not specified");
String releaseType = nonOptionArgs.get(1);
ReleaseType type = ReleaseType.from(releaseType);
String buildInfoLocation = nonOptionArgs.get(2);
byte[] content = Files.readAllBytes(new File(buildInfoLocation).toPath());
BuildInfoResponse buildInfoResponse = this.objectMapper.readValue(new String(content), BuildInfoResponse.class);
ReleaseInfo releaseInfo = ReleaseInfo.from(buildInfoResponse.getBuildInfo());
this.service.promote(type.getRepo(), releaseInfo);
}
Aggregations