Fixed publishing docs
This commit is contained in:
@@ -64,7 +64,7 @@ public class Releaser {
|
||||
log.info("\n\n\n=== PUBLISHING DOCS ===\n\nPress ENTER to deploy the artifacts {}", MSG);
|
||||
boolean skipDocs = skipStep();
|
||||
if (!skipDocs) {
|
||||
this.project.publishDocs();
|
||||
this.project.publishDocs(changedVersion.version);
|
||||
}
|
||||
if (!changedVersion.isSnapshot()) {
|
||||
log.info("\n\n\n=== REVERTING CHANGES & BUMPING VERSION===\n\nPress ENTER to go back to snapshots and bump originalVersion by patch {}", MSG);
|
||||
|
||||
@@ -132,15 +132,16 @@ public class ReleaserProperties {
|
||||
/**
|
||||
* Command to be executed to bump versions. The new version will be passed under %s param
|
||||
*/
|
||||
private String bumpVersionsCommand = "./mvnw versions:set -DnewVersion=%s";
|
||||
private String bumpVersionsCommand = "./mvnw versions:set -DgenerateBackupPoms=false -DnewVersion=%s";
|
||||
|
||||
/**
|
||||
* Command to be executed to deploy a built project
|
||||
* Command to be executed to deploy a built project. If present "{{version}}" will be replaced by the
|
||||
* provided version
|
||||
*/
|
||||
private String[] publishDocsCommands = {
|
||||
"wget https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/ghpages.sh -O target/gh-pages.sh",
|
||||
"chmod +x target/gh-pages.sh",
|
||||
"./target/gh-pages.sh"
|
||||
"./target/gh-pages.sh -v {{version}} -b -c"
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
public class Project {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private static final String VERSION_MUSTACHE = "{{version}}";
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
private final ProcessExecutor executor;
|
||||
@@ -70,9 +71,10 @@ public class Project {
|
||||
this.executor.runCommand(commands, waitTimeInMinutes);
|
||||
}
|
||||
|
||||
public void publishDocs() {
|
||||
public void publishDocs(String version) {
|
||||
try {
|
||||
for (String command : this.properties.getMaven().getPublishDocsCommands()) {
|
||||
command = command.replace(VERSION_MUSTACHE, version);
|
||||
String[] commands = command.split(" ");
|
||||
runCommand(commands);
|
||||
}
|
||||
|
||||
@@ -89,13 +89,27 @@ public class ProjectTests {
|
||||
TestProcessExecutor executor = executor(properties);
|
||||
Project builder = new Project(properties, executor);
|
||||
|
||||
builder.publishDocs();
|
||||
builder.publishDocs("");
|
||||
|
||||
then(asString(file("/projects/builder/resolved/resolved.log")))
|
||||
.contains("file.txt");
|
||||
then(executor.counter).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_publish_docs_command_and_substitute_the_version() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setPublishDocsCommands(new String[] { "echo '{{version}}'" });
|
||||
properties.setWorkingDir(file("/projects/builder/resolved").getPath());
|
||||
TestProcessExecutor executor = executor(properties);
|
||||
Project builder = new Project(properties, executor);
|
||||
|
||||
builder.publishDocs("1.1.0.RELEASE");
|
||||
|
||||
then(asString(file("/projects/builder/resolved/resolved.log")))
|
||||
.contains("1.1.0.RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_publish_docs_command_took_too_long_to_execute() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
@@ -104,7 +118,7 @@ public class ProjectTests {
|
||||
properties.setWorkingDir(file("/projects/builder/unresolved").getPath());
|
||||
Project builder = new Project(properties, executor(properties));
|
||||
|
||||
thenThrownBy(builder::publishDocs).hasMessageContaining("Process waiting time of [0] minutes exceeded");
|
||||
thenThrownBy(() -> builder.publishDocs("")).hasMessageContaining("Process waiting time of [0] minutes exceeded");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,7 +164,7 @@ public class ProjectTests {
|
||||
}
|
||||
|
||||
@Override ProcessBuilder builder(String[] commands, String workingDir) {
|
||||
counter++;
|
||||
this.counter++;
|
||||
return super.builder(commands, workingDir)
|
||||
.redirectOutput(file("/projects/builder/resolved/resolved.log"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user