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);
}
}
}
Aggregations