Search in sources :

Example 1 with AdvancedBuildClient

use of org.jboss.pnc.restclient.AdvancedBuildClient in project bacon by project-ncl.

the class PigFacade method pushToBrew.

private static void pushToBrew(boolean reimport) {
    abortIfBuildDataAbsentFromContext();
    Map<String, PncBuild> builds = PigContext.get().getBuilds();
    String tagPrefix = getBrewTag(context().getPncImportResult().getVersion());
    List<PncBuild> buildsToPush = getBuildsToPush(builds);
    if (log.isInfoEnabled()) {
        log.info("Pushing the following builds to brew: {}", buildsToPush.stream().map(PncBuild::getId).collect(Collectors.toList()));
    }
    for (PncBuild build : buildsToPush) {
        BuildPushParameters request = BuildPushParameters.builder().tagPrefix(tagPrefix).reimport(reimport).build();
        // TODO: customize the timeout
        try (AdvancedBuildClient pushingClient = new AdvancedBuildClient(PncClientHelper.getPncConfiguration())) {
            BuildPushResult pushResult = pushingClient.executeBrewPush(build.getId(), request, 15L, TimeUnit.MINUTES);
            if (pushResult.getStatus() != BuildPushStatus.SUCCESS) {
                throw new RuntimeException("Failed to push build " + build.getId() + " to brew. Push result: " + pushResult);
            }
            log.info("{} pushed to brew ( {} ) ", build.getId(), UrlGenerator.generateBuildUrl(build.getId()));
        } catch (RemoteResourceException e) {
            throw new RuntimeException("Failed to push build " + build.getId() + " to brew (" + UrlGenerator.generateBuildUrl(build.getId()) + ")", e);
        }
    }
}
Also used : RemoteResourceException(org.jboss.pnc.client.RemoteResourceException) AdvancedBuildClient(org.jboss.pnc.restclient.AdvancedBuildClient) BuildPushParameters(org.jboss.pnc.dto.requests.BuildPushParameters) BuildPushResult(org.jboss.pnc.dto.BuildPushResult) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild)

Aggregations

PncBuild (org.jboss.pnc.bacon.pig.impl.pnc.PncBuild)1 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)1 BuildPushResult (org.jboss.pnc.dto.BuildPushResult)1 BuildPushParameters (org.jboss.pnc.dto.requests.BuildPushParameters)1 AdvancedBuildClient (org.jboss.pnc.restclient.AdvancedBuildClient)1