Search in sources :

Example 6 with BuildProcessException

use of org.jboss.pnc.executor.exceptions.BuildProcessException in project pnc by project-ncl.

the class DefaultBuildExecutor method destroyEnvironment.

private void destroyEnvironment(BuildExecutionSession buildExecutionSession) {
    try {
        RunningEnvironment runningEnvironment = buildExecutionSession.getRunningEnvironment();
        if (runningEnvironment != null) {
            userLog.info("Destroying build environment.");
            buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_ENV_DESTROYING);
            runningEnvironment.destroyEnvironment();
            userLog.info("Build environment destroyed.");
            buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_ENV_DESTROYED);
        } else {
            userLog.warn("Unable to destroy environment. Most likely due to cancelled operation.");
        }
    } catch (Throwable e) {
        throw new BuildProcessException(e);
    }
}
Also used : RunningEnvironment(org.jboss.pnc.spi.environment.RunningEnvironment) BuildProcessException(org.jboss.pnc.executor.exceptions.BuildProcessException)

Example 7 with BuildProcessException

use of org.jboss.pnc.executor.exceptions.BuildProcessException in project pnc by project-ncl.

the class DefaultBuildExecutor method retrieveRepositoryManagerResults.

private Void retrieveRepositoryManagerResults(DefaultBuildExecutionSession buildExecutionSession) {
    try {
        if (!buildExecutionSession.hasFailed() && !buildExecutionSession.isCanceled()) {
            ProcessStageUtils.logProcessStageBegin(BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER.toString(), "Collecting results from repository manager ...");
            buildExecutionSession.setStatus(BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER);
            RunningEnvironment runningEnvironment = buildExecutionSession.getRunningEnvironment();
            if (runningEnvironment == null) {
                return null;
            }
            RepositorySession repositorySession = runningEnvironment.getRepositorySession();
            if (repositorySession == null) {
                return null;
            }
            RepositoryManagerResult repositoryManagerResult = repositorySession.extractBuildArtifacts(true);
            buildExecutionSession.setRepositoryManagerResult(repositoryManagerResult);
            if (repositoryManagerResult.getCompletionStatus().isFailed()) {
                buildExecutionSession.setStatus(BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER_COMPLETED_WITH_ERROR);
            } else {
                buildExecutionSession.setStatus(BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER_COMPLETED_SUCCESS);
            }
        }
    } catch (Throwable e) {
        throw new BuildProcessException(e, buildExecutionSession.getRunningEnvironment());
    } finally {
        ProcessStageUtils.logProcessStageEnd(BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER.toString(), "Collected results from repository manager.");
    }
    return null;
}
Also used : RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult) RepositorySession(org.jboss.pnc.spi.repositorymanager.model.RepositorySession) RunningEnvironment(org.jboss.pnc.spi.environment.RunningEnvironment) BuildProcessException(org.jboss.pnc.executor.exceptions.BuildProcessException)

Example 8 with BuildProcessException

use of org.jboss.pnc.executor.exceptions.BuildProcessException in project pnc by project-ncl.

the class DefaultBuildExecutor method setUpEnvironment.

private CompletableFuture<Void> setUpEnvironment(DefaultBuildExecutionSession buildExecutionSession, RepositorySession repositorySession, DebugData debugData) {
    if (buildExecutionSession.isCanceled()) {
        return null;
    }
    ProcessStageUtils.logProcessStageBegin(BuildExecutionStatus.BUILD_ENV_SETTING_UP.toString(), "Setting up build environment ...");
    buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_ENV_SETTING_UP);
    BuildExecutionConfiguration buildExecutionConfiguration = buildExecutionSession.getBuildExecutionConfiguration();
    try {
        EnvironmentDriver envDriver = environmentDriverFactory.getDriver(buildExecutionConfiguration.getSystemImageType());
        StartedEnvironment startedEnv = envDriver.startEnvironment(buildExecutionConfiguration.getSystemImageId(), buildExecutionConfiguration.getSystemImageRepositoryUrl(), buildExecutionConfiguration.getSystemImageType(), repositorySession, debugData, buildExecutionSession.getAccessToken(), buildExecutionConfiguration.isTempBuild(), buildExecutionConfiguration.getGenericParameters());
        buildExecutionSession.setCancelHook(startedEnv::cancel);
        return waitForEnvironmentInitialization(buildExecutionSession, startedEnv);
    } catch (Throwable e) {
        throw new BuildProcessException(e);
    }
}
Also used : BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) EnvironmentDriver(org.jboss.pnc.spi.environment.EnvironmentDriver) StartedEnvironment(org.jboss.pnc.spi.environment.StartedEnvironment) BuildProcessException(org.jboss.pnc.executor.exceptions.BuildProcessException)

Aggregations

BuildProcessException (org.jboss.pnc.executor.exceptions.BuildProcessException)8 RunningEnvironment (org.jboss.pnc.spi.environment.RunningEnvironment)4 RepositorySession (org.jboss.pnc.spi.repositorymanager.model.RepositorySession)4 Date (java.util.Date)2 BuildStatus (org.jboss.pnc.enums.BuildStatus)2 BuildType (org.jboss.pnc.enums.BuildType)2 RepositoryType (org.jboss.pnc.enums.RepositoryType)2 BuildDriverResult (org.jboss.pnc.spi.builddriver.BuildDriverResult)2 DestroyableEnvironment (org.jboss.pnc.spi.environment.DestroyableEnvironment)2 EnvironmentDriver (org.jboss.pnc.spi.environment.EnvironmentDriver)2 ExecutorException (org.jboss.pnc.spi.executor.exceptions.ExecutorException)2 BuildExecution (org.jboss.pnc.spi.repositorymanager.BuildExecution)2 RepositoryManager (org.jboss.pnc.spi.repositorymanager.RepositoryManager)2 URI (java.net.URI)1 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 Consumer (java.util.function.Consumer)1