Search in sources :

Example 1 with PromotionRequest

use of io.spring.concourse.releasescripts.artifactory.payload.PromotionRequest in project spring-boot by spring-projects.

the class ArtifactoryService method promote.

/**
 * Move artifacts to a target repository in Artifactory.
 * @param targetRepo the targetRepo
 * @param releaseInfo the release information
 */
public void promote(String targetRepo, ReleaseInfo releaseInfo) {
    PromotionRequest request = getPromotionRequest(targetRepo);
    String buildName = releaseInfo.getBuildName();
    String buildNumber = releaseInfo.getBuildNumber();
    logger.info("Promoting " + buildName + "/" + buildNumber + " to " + request.getTargetRepo());
    RequestEntity<PromotionRequest> requestEntity = RequestEntity.post(URI.create(PROMOTION_URL + buildName + "/" + buildNumber)).contentType(MediaType.APPLICATION_JSON).body(request);
    try {
        this.restTemplate.exchange(requestEntity, String.class);
        logger.debug("Promotion complete");
    } catch (HttpClientErrorException ex) {
        boolean isAlreadyPromoted = isAlreadyPromoted(buildName, buildNumber, request.getTargetRepo());
        if (isAlreadyPromoted) {
            logger.info("Already promoted.");
        } else {
            logger.info("Promotion failed.");
            throw ex;
        }
    }
}
Also used : HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) PromotionRequest(io.spring.concourse.releasescripts.artifactory.payload.PromotionRequest)

Aggregations

PromotionRequest (io.spring.concourse.releasescripts.artifactory.payload.PromotionRequest)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1