Search in sources :

Example 16 with BuildResult

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

the class DefaultBuildExecutionSession method setStatus.

@Override
public void setStatus(BuildExecutionStatus status) {
    if (status.hasFailed() && failedReasonStatus == null) {
        if (status.equals(DONE_WITH_ERRORS) && executorException == null) {
            setException(new ExecutorException("FailedReasonStatus or executorException must be set before final DONE_WITH_ERRORS."));
        }
        log.debug("Setting status {} as failed reason for session {}.", status, getId());
        failedReasonStatus = status;
    }
    Optional<BuildResult> buildResult;
    if (status.isCompleted()) {
        buildResult = Optional.of(getBuildResult());
    } else {
        buildResult = Optional.empty();
    }
    BuildExecutionStatusChangedEvent statusChanged = new DefaultBuildExecutorStatusChangedEvent(this.status, status, getId(), null, buildResult, status.isCompleted());
    log.debug("Updating build execution task {} status to {}.", getId(), statusChanged);
    this.status = status;
    onBuildExecutionStatusChangedEvent.accept(statusChanged);
    log.debug("Fired events after build execution task {} update.", getId());
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)

Example 17 with BuildResult

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

the class BuildExecutionTest method shouldNotContinueBuildOnMavenError.

@Test
public void shouldNotContinueBuildOnMavenError() throws ExecutorException, InterruptedException, TimeoutException {
    BuildConfiguration buildConfiguration = configurationBuilder.buildFailingConfiguration(3, "build-failed-on-maven", null);
    Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
    ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
    runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper);
    checkBuildStatuses(statusChangedEvents, Arrays.asList(DONE_WITH_ERRORS, BUILD_ENV_DESTROYED, BUILD_ENV_DESTROYING));
    assertNoState(statusChangedEvents, BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildResult(org.jboss.pnc.spi.BuildResult) ObjectWrapper(org.jboss.pnc.common.util.ObjectWrapper) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with BuildResult

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

the class BuildResultMock method mock.

public static BuildResult mock(BuildStatus status) {
    BuildExecutionConfiguration buildExecutionConfig = BuildExecutionConfigurationMock.mockConfig();
    BuildDriverResult buildDriverResult = BuildDriverResultMock.mockResult(status);
    RepositoryManagerResult repositoryManagerResult = RepositoryManagerResultMock.mockResult();
    ExecutorException exception = buildException();
    CompletionStatus completionStatus;
    if (status.completedSuccessfully()) {
        completionStatus = CompletionStatus.SUCCESS;
    } else {
        completionStatus = CompletionStatus.FAILED;
    }
    return new BuildResult(completionStatus, Optional.of(new ProcessException("Test Exception.")), "", Optional.ofNullable(buildExecutionConfig), Optional.ofNullable(buildDriverResult), Optional.ofNullable(repositoryManagerResult), Optional.of(EnvironmentDriverResultMock.mock()), Optional.of(RepourResultMock.mock()));
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) ProcessException(org.jboss.pnc.spi.coordinator.ProcessException) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult) CompletionStatus(org.jboss.pnc.spi.coordinator.CompletionStatus)

Example 19 with BuildResult

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

the class BuildExecutionSessionMock method setStatus.

@Override
public void setStatus(BuildExecutionStatus status) {
    if (status.hasFailed() && failedReasonStatus == null) {
        if (status.equals(DONE_WITH_ERRORS)) {
            setException(new ExecutorException("Missing failedReasonStatus. Failed reason must be sat before final DONE_WITH_ERRORS."));
        }
        log.debug("Setting status {} as failed reason for session {}.", status, getId());
        failedReasonStatus = status;
    }
    Optional<BuildResult> buildResult;
    if (status.isCompleted()) {
        buildResult = Optional.of(getBuildResult());
    } else {
        buildResult = Optional.empty();
    }
    BuildExecutionStatusChangedEvent statusChanged = new BuildExecutorStatusChangedEventMock(this.status, status, getId(), null, buildResult, status.isCompleted());
    log.debug("Updating build execution task {} status to {}.", getId(), statusChanged);
    this.status = status;
    onBuildExecutionStatusChangedEvent.accept(statusChanged);
    log.debug("Fired events after build execution task {} update.", getId());
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)

Example 20 with BuildResult

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

the class BuildExecutionSessionMock method getBuildResult.

private BuildResult getBuildResult() {
    EnvironmentDriverResult environmentDriverResult = null;
    DebugData debugData = getRunningEnvironment() != null ? getRunningEnvironment().getDebugData() : null;
    if (debugData != null && debugData.isDebugEnabled()) {
        environmentDriverResult = new EnvironmentDriverResult(CompletionStatus.SUCCESS, "", Optional.of(debugData.getSshCredentials()));
    }
    CompletionStatus completionStatus = CompletionStatus.SUCCESS;
    if (executorException == null) {
        if (failedReasonStatus != null) {
            switch(failedReasonStatus) {
                case BUILD_ENV_SETUP_COMPLETE_WITH_ERROR:
                case COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER_COMPLETED_WITH_ERROR:
                case SYSTEM_ERROR:
                    completionStatus = CompletionStatus.SYSTEM_ERROR;
                    break;
                case BUILD_COMPLETED_WITH_ERROR:
                    completionStatus = CompletionStatus.FAILED;
                    break;
                case CANCELLED:
                    completionStatus = CompletionStatus.CANCELLED;
                    break;
                case DONE_WITH_ERRORS:
                    executorException = new ExecutorException("DONE_WITH_ERRORS cannot be set as failed reason.");
                    break;
            }
        }
    }
    ProcessException processException = null;
    if (executorException != null) {
        processException = new ProcessException(executorException);
        completionStatus = CompletionStatus.SYSTEM_ERROR;
    }
    log.debug("Returning result of task {}.", getId());
    return new BuildResult(completionStatus, Optional.ofNullable(processException), "", Optional.ofNullable(buildExecutionConfiguration), Optional.ofNullable(buildDriverResult), Optional.ofNullable(repositoryManagerResult), Optional.ofNullable(environmentDriverResult), Optional.empty());
}
Also used : ProcessException(org.jboss.pnc.spi.coordinator.ProcessException) BuildResult(org.jboss.pnc.spi.BuildResult) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) DebugData(org.jboss.pnc.spi.builddriver.DebugData) EnvironmentDriverResult(org.jboss.pnc.spi.environment.EnvironmentDriverResult) CompletionStatus(org.jboss.pnc.spi.coordinator.CompletionStatus)

Aggregations

BuildResult (org.jboss.pnc.spi.BuildResult)22 BuildExecutionStatusChangedEvent (org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)11 ExecutorException (org.jboss.pnc.spi.executor.exceptions.ExecutorException)10 Test (org.junit.Test)10 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)9 ObjectWrapper (org.jboss.pnc.common.util.ObjectWrapper)8 HashSet (java.util.HashSet)7 BuildExecutionConfiguration (org.jboss.pnc.spi.executor.BuildExecutionConfiguration)7 BuildExecutionStatus (org.jboss.pnc.enums.BuildExecutionStatus)6 BuildDriverResult (org.jboss.pnc.spi.builddriver.BuildDriverResult)6 Consumer (java.util.function.Consumer)5 Inject (javax.inject.Inject)5 RepositoryManagerResult (org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Set (java.util.Set)4 Configuration (org.jboss.pnc.common.Configuration)4 BuildDriverFactory (org.jboss.pnc.executor.servicefactories.BuildDriverFactory)4 EnvironmentDriverFactory (org.jboss.pnc.executor.servicefactories.EnvironmentDriverFactory)4 RepositoryManagerFactory (org.jboss.pnc.executor.servicefactories.RepositoryManagerFactory)4