Skip to content

Commit

Permalink
Automation: added method for setting exit value
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Bennetts <[email protected]>
  • Loading branch information
psiinon committed Nov 29, 2024
1 parent 423ce96 commit 26b5ccd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions addOns/automation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Active scan policy job.
- Add job to configure the active scanner, `activeScan-config`.
- Allow to enable/disable jobs (Issue 5845).
- Method to allow the user to set the exit code via a script.

### Changed
- Updated automation framework documentation and templates for `activeScan` job to reflect changes to the default value of threadPerHost parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public class ExtensionAutomation extends ExtensionAdaptor implements CommandLine

private AutomationPanel automationPanel;

private Integer exitOverride;

public ExtensionAutomation() {
super(NAME);
setI18nPrefix(PREFIX);
Expand Down Expand Up @@ -696,13 +698,23 @@ private void runPlanCommandLine(String source) {
}

AutomationProgress progress = runAutomationFile(source);
if (progress == null || progress.hasErrors()) {
if (exitOverride != null) {
setExitStatus(exitOverride, "set by user", false);
} else if (progress == null || progress.hasErrors()) {
setExitStatus(1, "plan errors", false);
} else if (progress.hasWarnings()) {
setExitStatus(2, "plan warnings", false);
}
}

public Integer getExitOverride() {
return exitOverride;
}

public void setExitOverride(Integer exitOverride) {
this.exitOverride = exitOverride;
}

private static URI createUri(String source) {
try {
new java.net.URI(source).toURL();
Expand Down

0 comments on commit 26b5ccd

Please sign in to comment.