Search in sources :

Example 1 with BuildPushStatus

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);
}
Also used : BuildPushStatus(org.jboss.pnc.enums.BuildPushStatus) BuildImportRequest(org.jboss.pnc.api.causeway.dto.push.BuildImportRequest) BuildPushResult(org.jboss.pnc.dto.BuildPushResult) BuildRecordPushResult(org.jboss.pnc.model.BuildRecordPushResult)

Example 2 with BuildPushStatus

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);
}
Also used : Base32LongID(org.jboss.pnc.model.Base32LongID) BuildPushStatus(org.jboss.pnc.enums.BuildPushStatus) ProcessManagerException(org.jboss.pnc.spi.exception.ProcessManagerException) BuildRecordPushResult(org.jboss.pnc.model.BuildRecordPushResult) BuildRecord(org.jboss.pnc.model.BuildRecord)

Aggregations

BuildPushStatus (org.jboss.pnc.enums.BuildPushStatus)2 BuildRecordPushResult (org.jboss.pnc.model.BuildRecordPushResult)2 BuildImportRequest (org.jboss.pnc.api.causeway.dto.push.BuildImportRequest)1 BuildPushResult (org.jboss.pnc.dto.BuildPushResult)1 Base32LongID (org.jboss.pnc.model.Base32LongID)1 BuildRecord (org.jboss.pnc.model.BuildRecord)1 ProcessManagerException (org.jboss.pnc.spi.exception.ProcessManagerException)1