Updated exit codes and guarded against no projects to run

- exit code for build unstable resulted in batch being failed - migrated to completed build status and manually checks the execution result
- added a guard against no projects to run when marking the run post release tasks only option

Fixes gh-190, gh-191
This commit is contained in:
Marcin Grzejszczak
2020-03-05 18:32:30 +01:00
parent 50a4155d1c
commit 731d68ef50
5 changed files with 200 additions and 11 deletions

View File

@@ -134,8 +134,9 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
contribution.getStepExecution().getExecutionContext()
.put("entity", entity);
if (result.isFailureOrUnstable()) {
log.warn("The execution of [{}] failed or was unstable",
entity.getReleaserTaskType().getSimpleName());
log.warn("The execution of [{}] failed [{}] / unstable [{}]",
entity.getReleaserTaskType().getSimpleName(),
result.isFailure(), result.isUnstable());
contribution.getStepExecution().getExecutionContext()
.put("errors", errors);
}
@@ -212,8 +213,8 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
return stepExecution.getExitStatus();
}
else if (result.isUnstable()) {
return new ExitStatus(BuildUnstableException.EXIT_CODE,
BuildUnstableException.DESCRIPTION);
return ExitStatus.COMPLETED
.addExitDescription(BuildUnstableException.DESCRIPTION);
}
else if (result.isFailure()) {
return ExitStatus.FAILED;
@@ -226,6 +227,10 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
@Override
public ExecutionResult runReleaseTasks(Options options, ReleaserProperties properties,
ProjectsToRun projectsToRun, TasksToRun tasksToRun) {
if (properties.isPostReleaseTasksOnly() && options.metaRelease) {
log.info("Only post release tasks will be executed for the meta release");
return ExecutionResult.skipped();
}
ProjectsToReleaseGroups groups = new ProjectsToReleaseGroups(properties);
List<ReleaseGroup> releaseGroups = groups.toReleaseGroup(projectsToRun);
if (groups.hasGroups()) {
@@ -416,10 +421,7 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
+ execution.getExitStatus().getExitDescription() + "]"));
}
List<Exception> thrownExceptions = exceptionsThrownBySteps(execution);
if (thrownExceptions.isEmpty()) {
return ExecutionResult.success();
}
return ExecutionResult.failure(thrownExceptions);
return new ExecutionResult(thrownExceptions);
}
catch (JobExecutionException ex) {
return ExecutionResult.failure(ex);