diff --git a/pom.xml b/pom.xml
index 64092168..04eca340 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
org.springframework.cloud
spring-cloud-build
- 2.2.1.RELEASE
+ 2.2.3.RELEASE
diff --git a/releaser-core/src/main/java/releaser/internal/tech/BuildUnstableException.java b/releaser-core/src/main/java/releaser/internal/tech/BuildUnstableException.java
index dd8d68a8..68f51834 100644
--- a/releaser-core/src/main/java/releaser/internal/tech/BuildUnstableException.java
+++ b/releaser-core/src/main/java/releaser/internal/tech/BuildUnstableException.java
@@ -53,13 +53,13 @@ public class BuildUnstableException extends RuntimeException implements Serializ
public BuildUnstableException(Throwable cause) {
super(cause);
- log.error("\n\n" + DESCRIPTION, cause);
+ log.warn("\n\n" + DESCRIPTION, cause);
this.exceptions.add(cause);
}
public BuildUnstableException(String message, List throwables) {
this(throwables);
- log.error("\n\n" + DESCRIPTION + message + " with causes " + throwables);
+ log.warn("\n\n" + DESCRIPTION + message + " with causes " + throwables);
}
// for Jackson
diff --git a/releaser-spring/src/main/java/releaser/internal/spring/SpringBatchFlowRunner.java b/releaser-spring/src/main/java/releaser/internal/spring/SpringBatchFlowRunner.java
index ef1add8c..d13450f2 100644
--- a/releaser-spring/src/main/java/releaser/internal/spring/SpringBatchFlowRunner.java
+++ b/releaser-spring/src/main/java/releaser/internal/spring/SpringBatchFlowRunner.java
@@ -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 releaseGroups = groups.toReleaseGroup(projectsToRun);
if (groups.hasGroups()) {
@@ -416,10 +421,7 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
+ execution.getExitStatus().getExitDescription() + "]"));
}
List thrownExceptions = exceptionsThrownBySteps(execution);
- if (thrownExceptions.isEmpty()) {
- return ExecutionResult.success();
- }
- return ExecutionResult.failure(thrownExceptions);
+ return new ExecutionResult(thrownExceptions);
}
catch (JobExecutionException ex) {
return ExecutionResult.failure(ex);
diff --git a/releaser-spring/src/test/java/releaser/internal/spring/SpringBatchFlowRunnerTests.java b/releaser-spring/src/test/java/releaser/internal/spring/SpringBatchFlowRunnerTests.java
new file mode 100644
index 00000000..c9cb9370
--- /dev/null
+++ b/releaser-spring/src/test/java/releaser/internal/spring/SpringBatchFlowRunnerTests.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package releaser.internal.spring;
+
+import java.io.File;
+
+import org.assertj.core.api.BDDAssertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.BDDMockito;
+import releaser.internal.ReleaserProperties;
+import releaser.internal.options.Options;
+import releaser.internal.options.OptionsBuilder;
+import releaser.internal.project.ProjectVersion;
+import releaser.internal.project.Projects;
+import releaser.internal.tasks.ProjectPostReleaseReleaserTask;
+import releaser.internal.tasks.TrainPostReleaseReleaserTask;
+import releaser.internal.tech.ExecutionResult;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.SpringBootConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.test.context.ActiveProfiles;
+
+@SpringBootTest
+@ActiveProfiles("batch")
+class SpringBatchFlowRunnerTests {
+
+ ReleaserProperties releaserProperties = new ReleaserProperties();
+
+ @Test
+ void should_not_fail_the_release_when_project_post_release_task_fails(
+ @Autowired SpringBatchFlowRunner runner) {
+ Options options = new OptionsBuilder().interactive(false).options();
+ ProjectsToRun projectsToRun = projectsToRun(options, releaserProperties);
+ TasksToRun tasks = new TasksToRun(new MyProjectPostReleaseTask());
+
+ ExecutionResult executionResult = runner.runReleaseTasks(options,
+ releaserProperties, projectsToRun, tasks);
+
+ BDDAssertions.then(executionResult.isUnstable()).isTrue();
+ }
+
+ @Test
+ void should_execute_post_train_tasks_when_such_property_is_set(
+ @Autowired SpringBatchFlowRunner runner,
+ @Autowired ProjectsToRunFactory factory) {
+ Options options = new OptionsBuilder().interactive(false).metaRelease(true)
+ .options();
+ releaserProperties.setPostReleaseTasksOnly(true);
+ releaserProperties.getMetaRelease().setReleaseTrainProjectName("foo");
+ ProjectsToRun projectsToRun = projectsToRun(options, releaserProperties);
+ BDDMockito.given(factory.postReleaseTrain(BDDMockito.any()))
+ .willReturn(projectsToRun);
+ TasksToRun tasks = new TasksToRun(new MyPostTrainReleaseTask());
+
+ ExecutionResult executionResult = runner.runReleaseTasks(options,
+ releaserProperties, projectsToRun, tasks);
+
+ BDDAssertions.then(executionResult.isSkipped()).isTrue();
+
+ executionResult = runner.runPostReleaseTrainTasks(options, releaserProperties,
+ "post-release", tasks);
+
+ BDDAssertions.then(executionResult.isSuccess()).isTrue();
+ }
+
+ private ProjectsToRun projectsToRun(Options options,
+ ReleaserProperties releaserProperties) {
+ return new ProjectsToRun(new ProjectToRun.ProjectToRunSupplier("test",
+ () -> projectToRun(options, releaserProperties)));
+ }
+
+ private ProjectToRun projectToRun(Options options,
+ ReleaserProperties releaserProperties) {
+ return new ProjectToRun(new File("."),
+ new ProjectsFromBom(new Projects(), new ProjectVersion("foo", "0.0.1")),
+ new ProjectVersion("foo", "0.0.1"), releaserProperties, options);
+ }
+
+ @SpringBootConfiguration
+ @EnableAutoConfiguration
+ static class Config extends BatchConfiguration {
+
+ @Bean
+ ProjectsToRunFactory projectsToRunFactory() {
+ return BDDMockito.mock(ProjectsToRunFactory.class);
+ }
+
+ @Bean
+ ReleaserProperties releaserProperties() {
+ return new ReleaserProperties();
+ }
+
+ }
+
+}
+
+class MyProjectPostReleaseTask implements ProjectPostReleaseReleaserTask {
+
+ @Override
+ public String name() {
+ return "post-release-task";
+ }
+
+ @Override
+ public String shortName() {
+ return name();
+ }
+
+ @Override
+ public String header() {
+ return name();
+ }
+
+ @Override
+ public String description() {
+ return name();
+ }
+
+ @Override
+ public ExecutionResult runTask(Arguments args) {
+ return ExecutionResult.unstable(new RuntimeException("Some instability"));
+ }
+
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+
+}
+
+class MyPostTrainReleaseTask implements TrainPostReleaseReleaserTask {
+
+ @Override
+ public String name() {
+ return "train-post-release-task";
+ }
+
+ @Override
+ public String shortName() {
+ return name();
+ }
+
+ @Override
+ public String header() {
+ return name();
+ }
+
+ @Override
+ public String description() {
+ return name();
+ }
+
+ @Override
+ public ExecutionResult runTask(Arguments args) {
+ return ExecutionResult.success();
+ }
+
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+
+}
diff --git a/releaser-spring/src/test/resources/application-batch.yml b/releaser-spring/src/test/resources/application-batch.yml
new file mode 100644
index 00000000..ac49d82b
--- /dev/null
+++ b/releaser-spring/src/test/resources/application-batch.yml
@@ -0,0 +1,7 @@
+releaser:
+ git:
+ org-name: hello
+
+spring:
+ batch:
+ initialize-schema: always
\ No newline at end of file