use of org.jboss.pnc.enums.BuildPushStatus in project pnc by project-ncl.
the class BuildResultPushManager method push.
public Result push(BuildPushOperation buildPushOperation, String authToken) {
logger.info("Pushing to causeway {}", buildPushOperation.toString());
boolean added = inProgress.add(buildPushOperation.getBuildRecord().getId(), buildPushOperation.getTagPrefix(), buildPushOperation.getPushResultId().toString());
String externalBuildId = BuildMapper.idMapper.toDto(buildPushOperation.getBuildRecord().getId());
if (!added) {
logger.warn("Push for build.id {} already running.", externalBuildId);
return new Result(buildPushOperation.getPushResultId().toString(), externalBuildId, BuildPushStatus.REJECTED, "A push for this buildRecord is already running.");
}
BuildPushStatus pushStatus;
String message;
try {
BuildImportRequest buildImportRequest = createCausewayPushRequest(buildPushOperation.getBuildRecord(), buildPushOperation.getTagPrefix(), URI.create(String.format(buildPushOperation.getCompleteCallbackUrlTemplate(), externalBuildId)), authToken, buildPushOperation.getPushResultId(), buildPushOperation.isReImport());
boolean successfullyStarted = causewayClient.importBuild(buildImportRequest, authToken);
if (successfullyStarted) {
pushStatus = BuildPushStatus.ACCEPTED;
message = "";
} else {
pushStatus = BuildPushStatus.SYSTEM_ERROR;
message = "Failed to push to Causeway.";
}
} catch (RuntimeException ex) {
logger.error("Failed to push to Causeway.", ex);
pushStatus = BuildPushStatus.SYSTEM_ERROR;
message = "Failed to push to Causeway: " + ex.getMessage();
}
if (!BuildPushStatus.ACCEPTED.equals(pushStatus)) {
inProgress.remove(buildPushOperation.getBuildRecord().getId());
}
return new Result(buildPushOperation.getPushResultId().toString(), externalBuildId, pushStatus, message);
}
use of org.jboss.pnc.enums.BuildPushStatus in project pnc by project-ncl.
the class ProductMilestoneReleaseManager method storeBuildRecordPush.
private void storeBuildRecordPush(BuildImportResultRest buildRest, ProductMilestoneRelease productMilestoneRelease) {
Base32LongID recordId = BuildMapper.idMapper.toEntity(buildRest.getBuildRecordId());
BuildRecord record = buildRecordRepository.queryById(recordId);
if (record == null) {
log.error("No record found for record id: {}, skipped saving info: {}", recordId, buildRest);
return;
}
BuildPushStatus status;
try {
status = convertStatus(buildRest.getStatus());
} catch (ProcessManagerException e) {
log.error("Cannot convert status.", e);
throw new RuntimeException("Cannot convert status.", e);
}
BuildRecordPushResult buildRecordPush = BuildRecordPushResult.newBuilder().id(Sequence.nextId()).buildRecord(record).status(status).brewBuildId(buildRest.getBrewBuildId()).brewBuildUrl(buildRest.getBrewBuildUrl()).tagPrefix(// TODO tag!
"").productMilestoneRelease(productMilestoneRelease).build();
buildRecordPushResultRepository.save(buildRecordPush);
}
Aggregations