Skip to content

Commit

Permalink
feat: Allow to continue template execution using "ignoreError" proper…
Browse files Browse the repository at this point in the history
…ty (#1550)

* feat: Allow to continue template execution using "ignoreError" property
  • Loading branch information
BenjaminDecreusefond authored Nov 21, 2024
1 parent 6c2f3c2 commit 97e9832
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ExecutorContext {
private boolean refresh;
private boolean refreshOnly;
private boolean showHeader;
private boolean ignoreError;
private String accessToken;
private String moduleSshKey;
private String commitId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public ExecutorContext execute(Job job, String stepId, Flow flow) {

executorContext.setCommandList(flow.getCommands());
executorContext.setType(flow.getType());
executorContext.setIgnoreError(flow.isIgnoreError());
executorContext.setTerraformVersion(job.getWorkspace().getTerraformVersion());
if (job.getOverrideSource() == null) {
executorContext.setSource(job.getWorkspace().getSource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Flow {
private String type;
private String team;
private String name;

private boolean ignoreError = false;
private String error;
private int step;
List<Command> commands;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class TerraformJob {
private boolean showHeader;
private boolean refresh;
private boolean refreshOnly;
private boolean ignoreError;
private String moduleSshKey;
private String commitId;
private boolean tofu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public ExecutorJobResult plan(TerraformJob terraformJob, File workingDirectory,
null).get();
}

if(exitCode != 1) {
if(exitCode != 1 || terraformJob.isIgnoreError()) {
executionPlan = true;
}

log.warn("Terraform plan Executed Successfully: {} Exit Code: {}", executionPlan, exitCode);
log.warn("Terraform plan Executed: {} Exit Code: {}", executionPlan, exitCode);

scriptAfterSuccessPlan = executePostOperationScripts(terraformJob, terraformWorkingDir, planOutput, executionPlan);

Expand All @@ -142,7 +142,6 @@ public ExecutorJobResult plan(TerraformJob terraformJob, File workingDirectory,
result.setExitCode(1);
}
return result;

}

@Override
Expand Down

0 comments on commit 97e9832

Please sign in to comment.