Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation: added method for setting exit value #5966

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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