Added post release only option

This commit is contained in:
Marcin Grzejszczak
2018-10-31 10:27:18 +01:00
parent 600dcb0cb4
commit 2cfc8e1714
6 changed files with 54 additions and 6 deletions

View File

@@ -298,6 +298,7 @@ Defaults to Sleuth and Contract samples.
The following properties are used for both meta release and a release of an individual module.
- `releaser.post-release-tasks-only` - If set to `true` will run only post release tasks. Defaults to `false`.
- `releaser.meta-release.release-train-project-name` - Name of the project that represents the BOM of the release train. Defaults to `spring-cloud-release`.
- `releaser.git.fetch-versions-from-git` - If `true` then should fill the map of versions from Git. If `false` then picks fixed versions.
- `releaser.git.clone-destination-dir` - Where should the Spring Cloud Release repo get cloned to. If null defaults to a temporary directory.

View File

@@ -288,6 +288,7 @@ Defaults to Sleuth and Contract samples.
The following properties are used for both meta release and a release of an individual module.
- `releaser.post-release-tasks-only` - If set to `true` will run only post release tasks. Defaults to `false`.
- `releaser.meta-release.release-train-project-name` - Name of the project that represents the BOM of the release train. Defaults to `spring-cloud-release`.
- `releaser.git.fetch-versions-from-git` - If `true` then should fill the map of versions from Git. If `false` then picks fixed versions.
- `releaser.git.clone-destination-dir` - Where should the Spring Cloud Release repo get cloned to. If null defaults to a temporary directory.

View File

@@ -43,6 +43,11 @@ public class ReleaserProperties implements Serializable {
*/
private String workingDir;
/**
* If set to {@code true} will run only post release tasks
*/
private boolean postReleaseTasksOnly = false;
private Git git = new Git();
private Pom pom = new Pom();
@@ -860,6 +865,14 @@ public class ReleaserProperties implements Serializable {
this.template = template;
}
public boolean isPostReleaseTasksOnly() {
return this.postReleaseTasksOnly;
}
public void setPostReleaseTasksOnly(boolean postReleaseTasksOnly) {
this.postReleaseTasksOnly = postReleaseTasksOnly;
}
@Override public String toString() {
return "ReleaserProperties{" + "workingDir='" + this.workingDir + '\'' + ", git=" + this.git
+ ", pom=" + this.pom + ", maven=" + this.maven + ", gradle=" + this.gradle + ", sagan="

View File

@@ -3,6 +3,7 @@ package org.springframework.cloud.release.internal.post;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -91,7 +92,8 @@ public class PostReleaseActions implements Closeable {
log.info("Updated all samples!");
List<String> exceptionMessages = projectAndExceptions.stream()
.filter(ProjectAndException::hasException)
.map(e -> "Project [" + e.key + "] for url [" + e.url + "] has exception [" + e.ex + "]")
.map(e -> "Project [" + e.key + "] for url [" + e.url + "] has exception [" + Arrays
.toString(e.ex.getStackTrace()) + "]")
.collect(Collectors.toList());
if (!exceptionMessages.isEmpty()) {
log.warn("Exceptions were found while updating samples");
@@ -110,7 +112,7 @@ public class PostReleaseActions implements Closeable {
Projects postRelease = projects
.postReleaseSnapshotVersion(this.properties.getMetaRelease().getProjectsToSkip());
log.info("Versions to update the samples with \n" + postRelease.stream()
.map(v -> "[" + v.projectName + ":" + v.version + "]")
.map(v -> "[" + v.projectName + " => " + v.version + "]")
.collect(Collectors.joining("\n")));
return value.stream()
.map(url -> run(key, url, () ->

View File

@@ -55,11 +55,19 @@ public class SpringReleaser {
public void release(Options options) {
ProjectsAndVersion projectsAndVersion = null;
// if meta release, first clone, then continue as usual
if (options.metaRelease) {
log.info("Meta Release picked. Will iterate over all projects and perform release of each one");
this.properties.getGit().setFetchVersionsFromGit(false);
this.properties.getMetaRelease().setEnabled(options.metaRelease);
prepareForMetaRelease(options);
}
if (this.properties.isPostReleaseTasksOnly()) {
log.info("Skipping release process and moving only to post release");
this.optionsProcessor.postReleaseOptions(options, postReleaseOptionsAgs(options, projectsAndVersion));
return;
}
performReleaseAndPostRelease(options, projectsAndVersion);
}
private void performReleaseAndPostRelease(Options options, ProjectsAndVersion projectsAndVersion) {
if (options.metaRelease) {
ReleaserProperties original = this.properties.copy();
log.debug("The following properties were found [{}]", original);
metaReleaseProjects(options)
@@ -73,6 +81,12 @@ public class SpringReleaser {
this.optionsProcessor.postReleaseOptions(options, postReleaseOptionsAgs(options, projectsAndVersion));
}
private void prepareForMetaRelease(Options options) {
log.info("Meta Release picked. Will iterate over all projects and perform release of each one");
this.properties.getGit().setFetchVersionsFromGit(false);
this.properties.getMetaRelease().setEnabled(options.metaRelease);
}
void processProjectForMetaRelease(ReleaserProperties copy, Options options, String project) {
log.info("Original properties [\n\n{}\n\n]", copy);
File clonedProjectFromOrg = this.releaser.clonedProjectFromOrg(project);

View File

@@ -87,6 +87,23 @@ public class SpringReleaserTests {
assertBuildCommand(this.aware2.properties);
}
@Test
public void should_only_call_post_release() {
SpringReleaser releaser = stubbedSpringReleaser();
this.properties.setPostReleaseTasksOnly(true);
releaser.release(new OptionsBuilder().metaRelease(false).options());
thenOnlyCallsPostRelease();
}
private void thenOnlyCallsPostRelease() {
BDDMockito.then(this.optionsProcessor).should().postReleaseOptions(
BDDMockito.any(Options.class), BDDMockito.any(Args.class));
BDDMockito.then(this.optionsProcessor).should(BDDMockito.never())
.processOptions(BDDMockito.any(Options.class), BDDMockito.any(Args.class));
}
private void assertBuildCommand(Queue<ReleaserProperties> properties) {
BDDAssertions.then(properties.poll().getMaven().getBuildCommand())
.isEqualTo("./scripts/noIntegration.sh");