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());
}
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);
}
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()));
}
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());
}
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());
}
Aggregations