use of org.jboss.pnc.client.ClientException in project bacon by project-ncl.
the class PncEntitiesImporter method setBrewTagPrefix.
/**
* Override the default brewTagPrefix for the product version with the one specified in the pig configuration This
* only happens if the brewTagPrefix in the pig configuration is not null/empty
*/
private void setBrewTagPrefix(ProductVersion productVersion) {
String brewTagPrefix = pigConfiguration.getBrewTagPrefix();
if (brewTagPrefix != null && !brewTagPrefix.isEmpty()) {
log.info("Updating the product version's brewTagPrefix with: {}", brewTagPrefix);
Map<String, String> attributes = productVersion.getAttributes();
attributes.put(Attributes.BREW_TAG_PREFIX, brewTagPrefix);
ProductVersion update = productVersion.toBuilder().attributes(attributes).build();
try {
versionClient.update(productVersion.getId(), update);
} catch (ClientException e) {
throw new RuntimeException("Failed to update the brew tag prefix of the product version", e);
}
}
}
use of org.jboss.pnc.client.ClientException in project bacon by project-ncl.
the class PncEntitiesImporter method updateBuildConfig.
private BuildConfiguration updateBuildConfig(BuildConfigData data, BuildConfiguration existing) {
String configId = data.getId();
BuildConfiguration buildConfiguration = generatePncBuildConfig(data.getNewConfig(), existing);
try {
buildConfigClient.update(configId, buildConfiguration);
return buildConfigClient.getSpecific(configId);
} catch (ClientException e) {
throw new RuntimeException("Failed to update build configuration " + configId, e);
}
}
use of org.jboss.pnc.client.ClientException in project bacon by project-ncl.
the class PncEntitiesImporter method generateProduct.
private Product generateProduct() {
ProductConfig productConfig = pigConfiguration.getProduct();
Product product = Product.builder().name(productConfig.getName()).abbreviation(productConfig.getAbbreviation()).build();
try {
return productClient.createNew(product);
} catch (ClientException e) {
throw new RuntimeException("Failed to create the product", e);
}
}
use of org.jboss.pnc.client.ClientException in project bacon by project-ncl.
the class PncBuild method getBuildLog.
/**
* Get the build log of the build on demand and result if cached. If the method is called again, the cached content
* will be served if not null
*
* @return the logs of the build
*/
public List<String> getBuildLog() {
// use cached buildLog if present
if (buildLog != null) {
return buildLog;
}
try (BuildClient buildClient = new BuildClient(PncClientHelper.getPncConfiguration())) {
Optional<InputStream> maybeBuildLogs = buildClient.getBuildLogs(id);
if (maybeBuildLogs.isPresent()) {
try (InputStream inputStream = maybeBuildLogs.get()) {
buildLog = readLog(inputStream);
}
} else {
log.debug("Couldn't find logs for build id: {} ( {} )", id, UrlGenerator.generateBuildUrl(id));
buildLog = Collections.emptyList();
}
return buildLog;
} catch (ClientException | IOException e) {
throw new RuntimeException("Failed to get build log for " + id + " (" + UrlGenerator.generateBuildUrl(id) + ")", e);
}
}
use of org.jboss.pnc.client.ClientException in project bacon by project-ncl.
the class BuildInfoCollector method getLatestBuild.
public PncBuild getLatestBuild(String configId, BuildSearchType searchType) {
try {
BuildsFilterParameters filter = new BuildsFilterParameters();
Optional<String> queryParam;
switch(searchType) {
case ANY:
queryParam = query("status==%s", BuildStatus.SUCCESS);
break;
case PERMANENT:
queryParam = query("status==%s;temporaryBuild==%s", BuildStatus.SUCCESS, false);
break;
case TEMPORARY:
// NCL-5943 Cannot ignore permanent(regular) builds because they cause NO_REBUILD_REQUIRED even for
// temporary builds. That means "latest build" for a temporary build can be permanent(regular).
queryParam = query("status==%s", BuildStatus.SUCCESS);
break;
default:
queryParam = Optional.empty();
}
// Note: sort by id not allowed
Iterator<Build> buildIterator = buildConfigClient.getBuilds(configId, filter, of("=desc=submitTime"), queryParam).iterator();
if (!buildIterator.hasNext()) {
throw new NoSuccessfulBuildException(configId);
}
Build build = buildIterator.next();
PncBuild result = new PncBuild(build);
result.addBuiltArtifacts(toList(buildClient.getBuiltArtifacts(build.getId())));
return result;
} catch (ClientException e) {
throw new RuntimeException("Failed to get latest successful build for " + configId, e);
}
}
Aggregations