Search in sources :

Example 1 with BuildInfoResponse

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());
}
Also used : ReleaseType(io.spring.concourse.releasescripts.ReleaseType) BuildInfo(io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse.BuildInfo) ReleaseInfo(io.spring.concourse.releasescripts.ReleaseInfo) BuildInfoResponse(io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse) File(java.io.File)

Example 2 with BuildInfoResponse

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;
    }
}
Also used : Status(io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse.Status) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) Status(io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse.Status) BuildInfoResponse(io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse)

Example 3 with BuildInfoResponse

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);
}
Also used : ReleaseType(io.spring.concourse.releasescripts.ReleaseType) ReleaseInfo(io.spring.concourse.releasescripts.ReleaseInfo) BuildInfoResponse(io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse) File(java.io.File)

Aggregations

BuildInfoResponse (io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse)3 ReleaseInfo (io.spring.concourse.releasescripts.ReleaseInfo)2 ReleaseType (io.spring.concourse.releasescripts.ReleaseType)2 File (java.io.File)2 BuildInfo (io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse.BuildInfo)1 Status (io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse.Status)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1