Skip to content

Commit

Permalink
ignore failure on clean
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwarz-eitco-de committed Jun 20, 2024
1 parent f8df912 commit bccaf76
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/main/java/de/eitco/cicd/dotnet/DotnetExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,26 @@ private static class ExecutionOptions {
private boolean inheritIo = true;

public ExecutionOptions ignoreResult() {
ignoreResult = true;
return this;

ExecutionOptions result = new ExecutionOptions();
result.inheritIo = inheritIo;
result.ignoreResult = true;
return result;
}

public ExecutionOptions silent() {
inheritIo = false;
return this;
ExecutionOptions result = new ExecutionOptions();
result.inheritIo = false;
result.ignoreResult = ignoreResult;
return result;
}

public ExecutionOptions mergeIgnoreResult(boolean ignoreResult) {
ExecutionOptions result = new ExecutionOptions();
result.inheritIo = inheritIo;
result.ignoreResult = ignoreResult || this.ignoreResult;

this.ignoreResult = ignoreResult || this.ignoreResult;

return this;
return result;
}
}

Expand Down Expand Up @@ -123,19 +129,19 @@ private List<String> buildCommand(List<String> parameters, Map<String, String> p
return command;
}

private void retry(int times, List<String> parameters, Set<String> obfuscation, Map<String, String> propertyOverrides) throws MojoExecutionException {
private void retry(int times, ExecutionOptions executionOptions, List<String> parameters, Set<String> obfuscation, Map<String, String> propertyOverrides) throws MojoExecutionException {

for (int index = 0; index < times; index++) {

int returnCode = execute(defaultOptions().ignoreResult(), parameters, obfuscation, propertyOverrides);
int returnCode = execute(executionOptions.ignoreResult(), parameters, obfuscation, propertyOverrides);

if (returnCode == 0) {

return;
}
}

execute(defaultOptions(), parameters, obfuscation, propertyOverrides);
execute(executionOptions, parameters, obfuscation, propertyOverrides);
}

public void build(String assemblyVersion, String vendor, String configuration) throws MojoExecutionException {
Expand All @@ -156,7 +162,7 @@ public void build(String assemblyVersion, String vendor, String configuration) t
parameters.add("--configuration=" + configuration);
}

retry(1, parameters, Set.of(), propertyOverrides);
retry(1, defaultOptions(), parameters, Set.of(), propertyOverrides);
}

public void pack(String vendor, String description, String repositoryUrl) throws MojoExecutionException {
Expand Down Expand Up @@ -350,6 +356,7 @@ private static void appendCredentials(String username, String apiToken, List<Str

public void clean() throws MojoExecutionException {

execute(defaultOptions(), List.of("clean"), Set.of(), Map.of("Version", version));
retry(1, defaultOptions().ignoreResult(), List.of("clean"), Set.of(), Map.of("Version", version));

}
}

0 comments on commit bccaf76

Please sign in to comment.