use of org.jboss.pnc.spi.executor.exceptions.ExecutorException 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.executor.exceptions.ExecutorException 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.executor.exceptions.ExecutorException 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.executor.exceptions.ExecutorException 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());
}
use of org.jboss.pnc.spi.executor.exceptions.ExecutorException in project pnc by project-ncl.
the class BuildExecutorTriggerer method executeBuild.
public BuildExecutionSession executeBuild(BuildExecutionConfiguration buildExecutionConfig, String callbackUrl, String accessToken) throws CoreException, ExecutorException {
Consumer<BuildExecutionStatusChangedEvent> onExecutionStatusChange = (statusChangedEvent) -> {
log.debug("Received BuildExecutionStatusChangedEvent: " + statusChangedEvent);
if (statusChangedEvent.isFinal() && callbackUrl != null && !callbackUrl.isEmpty()) {
statusChangedEvent.getBuildResult().ifPresent((buildResult) -> bpmNotifier.sendBuildExecutionCompleted(callbackUrl, buildResult, accessToken));
}
};
BuildExecutionSession buildExecutionSession = buildExecutor.startBuilding(buildExecutionConfig, onExecutionStatusChange, accessToken);
return buildExecutionSession;
}
Aggregations