Search in sources :

Example 6 with CoreException

use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.

the class BpmBuildScheduler method startBuilding.

@Override
public void startBuilding(BuildTask buildTask) throws CoreException {
    try {
        Map<String, String> genericParameters = buildTask.getBuildConfigurationAudited().getGenericParameters();
        BpmBuildTask task = new BpmBuildTask(buildTask);
        if (useNewProcessForBuild(genericParameters, bpmConfig.isNewBpmForced())) {
            task.setGlobalConfig(globalConfig);
            task.setBpmConfig(bpmConfig);
            task.setJsonEncodedProcessParameters(false);
            restConnector.startProcess(bpmConfig.getBpmNewBuildProcessName(), task.getExtendedProcessParameters(), buildTask.getId(), task.getAccessToken());
        } else {
            manager.startTask(task);
        }
    } catch (Exception e) {
        throw new CoreException("Error while trying to startBuilding with BpmBuildScheduler.", e);
    }
}
Also used : BpmBuildTask(org.jboss.pnc.bpm.task.BpmBuildTask) CoreException(org.jboss.pnc.spi.exception.CoreException) CoreException(org.jboss.pnc.spi.exception.CoreException)

Example 7 with CoreException

use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.

the class LocalBuildScheduler method startBuilding.

@Override
public void startBuilding(BuildTask buildTask) throws CoreException {
    Consumer<BuildExecutionStatusChangedEvent> onBuildExecutionStatusChangedEvent = (statusChangedEvent) -> {
        try {
            log.debug("Received execution status update {}.", statusChangedEvent);
            if (statusChangedEvent.getNewStatus().isCompleted()) {
                BuildResult buildResult = statusChangedEvent.getBuildResult().get();
                log.debug("Notifying build execution completed {}.", statusChangedEvent);
                buildCoordinator.completeBuild(buildTask, buildResult);
            }
        } catch (Throwable t) {
            log.error("Failed to notify build completion.", t);
        }
    };
    String contentId = ContentIdentityManager.getBuildContentId(buildTask.getId());
    BuildConfigurationAudited configuration = buildTask.getBuildConfigurationAudited();
    BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfiguration.build(buildTask.getId(), contentId, buildTask.getUser().getId().toString(), configuration.getBuildScript(), configuration.getId().toString(), configuration.getName(), configuration.getRepositoryConfiguration().getInternalUrl(), configuration.getScmRevision(), null, configuration.getRepositoryConfiguration().getExternalUrl(), configuration.getRepositoryConfiguration().isPreBuildSyncEnabled(), configuration.getBuildEnvironment().getSystemImageId(), configuration.getBuildEnvironment().getSystemImageRepositoryUrl(), configuration.getBuildEnvironment().getSystemImageType(), configuration.getBuildType(), buildTask.getBuildOptions().isKeepPodOnFailure(), configuration.getGenericParameters(), buildTask.getBuildOptions().isTemporaryBuild(), TimeUtils.generateTimestamp(buildTask.getBuildOptions().isTimestampAlignment(), buildTask.getBuildSetTask().getStartTime()), configuration.isBrewPullActive(), configuration.getDefaultAlignmentParams(), buildTask.getBuildOptions().getAlignmentPreference());
    try {
        buildExecutor.startBuilding(buildExecutionConfiguration, onBuildExecutionStatusChangedEvent, buildTask.getUser().getLoginToken());
    } catch (ExecutorException e) {
        throw new CoreException("Could not start build execution.", e);
    }
}
Also used : TimeUtils(org.jboss.pnc.common.util.TimeUtils) Logger(org.slf4j.Logger) BuildScheduler(org.jboss.pnc.coordinator.builder.BuildScheduler) ContentIdentityManager(org.jboss.pnc.model.utils.ContentIdentityManager) BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) BuildResult(org.jboss.pnc.spi.BuildResult) LoggerFactory(org.slf4j.LoggerFactory) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildExecutor(org.jboss.pnc.spi.executor.BuildExecutor) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) Inject(javax.inject.Inject) Consumer(java.util.function.Consumer) CoreException(org.jboss.pnc.spi.exception.CoreException) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent) ApplicationScoped(javax.enterprise.context.ApplicationScoped) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildResult(org.jboss.pnc.spi.BuildResult) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) CoreException(org.jboss.pnc.spi.exception.CoreException) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)

Example 8 with CoreException

use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.

the class ProductMilestoneReleaseManager method triggerRHPAMRelease.

/**
 * Trigger the release using the new RHPAM server
 *
 * @param milestone milestone to be released
 * @param accessToken access token to use to submit request
 * @param milestoneReleaseId the milestone id
 */
private ProductMilestoneRelease triggerRHPAMRelease(ProductMilestone milestone, String accessToken, Long milestoneReleaseId) {
    ProductMilestoneRelease release = new ProductMilestoneRelease();
    release.setId(milestoneReleaseId);
    release.setStartingDate(new Date());
    release.setMilestone(milestone);
    try (RestConnector restConnector = new RestConnector(bpmConfig)) {
        MilestoneReleaseTask releaseTask = new MilestoneReleaseTask(milestone, accessToken);
        releaseTask.setTaskId(bpmManager.getNextTaskId());
        releaseTask.setGlobalConfig(globalConfig);
        releaseTask.setJsonEncodedProcessParameters(false);
        restConnector.startProcess(bpmConfig.getBpmNewReleaseProcessId(), releaseTask.getExtendedProcessParameters(), Numbers.decimalToBase32(milestoneReleaseId), accessToken);
        return release;
    } catch (CoreException | ProcessManagerException e) {
        log.error("Error trying to start brew push task for milestone: {}", milestone.getId(), e);
        userLog.error("Release process creation failed.", e);
        release.setStatus(MilestoneCloseStatus.SYSTEM_ERROR);
        release.setEndDate(new Date());
        return release;
    }
}
Also used : RestConnector(org.jboss.pnc.bpm.RestConnector) CoreException(org.jboss.pnc.spi.exception.CoreException) ProcessManagerException(org.jboss.pnc.spi.exception.ProcessManagerException) MilestoneReleaseTask(org.jboss.pnc.bpm.task.MilestoneReleaseTask) ProductMilestoneRelease(org.jboss.pnc.model.ProductMilestoneRelease) Date(java.util.Date)

Example 9 with CoreException

use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.

the class ProductMilestoneReleaseManager method triggerRelease.

@Deprecated
private ProductMilestoneRelease triggerRelease(ProductMilestone milestone, String accessToken, Long milestoneReleaseId) {
    ProductMilestoneRelease release = new ProductMilestoneRelease();
    release.setId(milestoneReleaseId);
    release.setStartingDate(new Date());
    release.setMilestone(milestone);
    try {
        MilestoneReleaseTask releaseTask = new MilestoneReleaseTask(milestone, accessToken);
        Integer id = milestone.getId();
        releaseTask.<MilestoneReleaseResultRest>addListener(BpmEventType.BREW_IMPORT, r -> onPushResult(id, r));
        release.setStatus(MilestoneCloseStatus.IN_PROGRESS);
        bpmManager.startTask(releaseTask);
        userLog.info("Release process started.");
        productMilestoneCloseResultEvent.fire(mapper.toDTO(release));
        return release;
    } catch (CoreException e) {
        log.error("Error trying to start brew push task for milestone: {}", milestone.getId(), e);
        userLog.error("Release process creation failed.", e);
        release.setStatus(MilestoneCloseStatus.SYSTEM_ERROR);
        release.setEndDate(new Date());
        productMilestoneCloseResultEvent.fire(mapper.toDTO(release));
        return release;
    }
}
Also used : MilestoneReleaseResultRest(org.jboss.pnc.bpm.model.causeway.MilestoneReleaseResultRest) CoreException(org.jboss.pnc.spi.exception.CoreException) MilestoneReleaseTask(org.jboss.pnc.bpm.task.MilestoneReleaseTask) ProductMilestoneRelease(org.jboss.pnc.model.ProductMilestoneRelease) Date(java.util.Date)

Example 10 with CoreException

use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.

the class BuildConfigurationEndpointImpl method triggerBuild.

private Build triggerBuild(String id, OptionalInt rev, BuildParameters buildParams) throws BuildConflictException {
    try {
        logger.debug("Endpoint /build requested for buildConfigurationId: {}, revision: {}, parameters: {}", id, rev, buildParams);
        BuildOptions buildOptions = toBuildOptions(buildParams);
        String buildId = buildTriggerer.triggerBuild(Integer.parseInt(id), rev, buildOptions);
        return buildProvider.getSpecific(buildId);
    } catch (CoreException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : CoreException(org.jboss.pnc.spi.exception.CoreException) BuildOptions(org.jboss.pnc.spi.BuildOptions)

Aggregations

CoreException (org.jboss.pnc.spi.exception.CoreException)21 Inject (javax.inject.Inject)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 Consumer (java.util.function.Consumer)9 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)9 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)8 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)8 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)8 BuildStatus (org.jboss.pnc.enums.BuildStatus)7 BuildOptions (org.jboss.pnc.spi.BuildOptions)7 DatastoreException (org.jboss.pnc.spi.datastore.DatastoreException)7 BuildStatusChangedEvent (org.jboss.pnc.spi.events.BuildStatusChangedEvent)7 List (java.util.List)6 TestProjectConfigurationBuilder (org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder)6 Optional (java.util.Optional)5 Set (java.util.Set)5 BuildCoordinationStatus (org.jboss.pnc.enums.BuildCoordinationStatus)5 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)5 BuildSetStatusChangedEvent (org.jboss.pnc.spi.events.BuildSetStatusChangedEvent)5