Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

OS

Task Configuration

Scenario/Description

Linux


Scenario:

Based

Execution of an ls command.

Task instance success or failure depends on the exit code of the command

, the task instance is executed with success or failure

being executed. If the command is executed with exit code = 0, the

default behavior is that the Task Instance FAILED status is

task instance completes with Success status. Otherwise, the task instance status is Failed with exit code = 1.

This example shows the execution of

the

an ls command, including outputs for both success and failure cases.

Code Block
languagejs
titleExtension Output when File exists
linenumberstrue
collapsetrue
{
	"exit_code": 0,
	"status_description": "Task executed successfully",
	"invocation": {
		"extension": "ue-cmd",
		"version": "1.0.0",
		"fields": { ... }
	},
	"result": {
		"metadata": {
			"runtime_directory": "/tmp",
			"command": "ls existing_file.txt",
			"exit_code": 0
		},
		"command_json_output": "existing_file.txt"
	}
}


Code Block
languagejs
titleExtension Output when File does not exists
linenumberstrue
collapsetrue
{
	"exit_code": 1,
	"status_description": "Execution returned exit code other than 0",
	"invocation": {
		"extension": "ue-cmd",
		"version": "1.0.0",
		"fields": { ... }
	},
	"result": {
		"metadata": {
			"runtime_directory": "/tmp",
			"command": "ls non_existent.txt",
			"exit_code": 2
		},
		"command_json_output": null
	}
}


Linux

Scenario: Command execution that produces a valid JSON result:.

This example shows a command that produces JSON output on STDOUT. In such a case, the output is also visible in the task instance EXTENSION output.

Code Block
titleExtension Output containing JSON object
linenumberstrue
collapsetrue
{
	"exit_code": 0,
	"status_description": "Task executed successfully",
	"invocation": {
		"extension": "ue-cmd",
		"version": "1.0.0",
		"fields": {
			"action": "Run Command",
			"command": "echo '{\"name\": \"John\", \"age\": 30, \"city\": \"Athens\"}'",
			"additional_file": null
		}
	},
	"result": {
		"metadata": {
			"runtime_directory": "/tmp",
			"command": "echo '{\"name\": \"John\", \"age\": 30, \"city\": \"Athens\"}'",
			"exit_code": 0
		},
		"command_json_output": {
			"name": "John",
			"age": 30,
			"city": "Athens"
		}
	}
}


Linux

Scenario: Execution of a shell script stored in the Controller.

The example shows execution of script.sh. Environment variable ${UE_CMD_ADDFILE} points to the script full path referenced from Optional Additional File field.






Note: In this example, the reference to the environmental variable UE_CMD_ADDFILE is surrounded by quotes. This was done because the path to this variable contains spaces, so it must be quoted in order for the shell to resolve it correctly.

Linux

Scenario: Conditional execution of commands.

This example shows a scenario that depends on the result of grep. If there is a pattern match, a success message is displayed; otherwise, an error message is printed to indicate the pattern wasn't found.

Linux

Scenario: Command Stacking.

This example shows multiple commands being executed:

  • execute a shell script provided in the Optional Additional File field

  • pause for 2 seconds

  • print a message indicating that execution has completed.

Linux

Scenario: Redirection of output.

In this example, the contents of the current directory are listed in long format using ls -l, and then redirected to the output.log file. Afterwards, the contents are displayed through the cat command.


Windows

Scenario: PowerShell script execution.

The example shows execution of a PowerShell script provided by the Optional Additional File field referenced through the UE_CMD_ADDFILE environment variable.

Info

PowerShell can execute scripts when related execution policy is granted. For more information, refer to the official Microsoft website.


Info

PowerShell Scripts need to be saved with a .ps1 extension.


Windows

Scenario: Execution of a batch file.

The example shows execution of a batch file provided by the Optional Additional File field referenced through the UE_CMD_ADDFILE environment variable.

Info

Batch Scripts need to be saved with a .bat extension.


...

Field

Type

Description

Version Information

Action

Choice

The action performed upon the task execution. Available options:

  • Run Command

Introduced in 1.0.0

Optional Additional File

Script

A An optional field to include a file used either as a parameter in the command or as a script to be executed with an interpreter. This file can be referenced in the command line using the UE_CMD_ADDFILE environment variable. This field is particularly useful when the required files are not present on the agent’s filesystem, allowing the Controller to serve as the source for these files.

Introduced in 1.0.0

Command

Large Text

The Command Line to be executed. It should be provided as a single line. Any additional lines will be ignored.

Environment variable UC_CMD_ADDFILE can be used here to reference the additional file provided.

Required when Action is “Run Command”



Introduced in 1.0.0

Runtime Directory

Text

The Runtime Directory just before the execution of the command. While the Runtime Directory field is not mandatory, it is highly recommended to be configured. This ensures clarity about the directory from which the command is executed

Introduced in 1.0.0

...

Exit Code

Status

Status Description

Meaning

0

Success

“Task executed successfully. “

Exit code for successful executionIf the executed command succeeds, it returns an exit code of 0. The task will reflect this success by also returning exit code = 0.

1

Failure

““Execution Failed: <<Error Description>>”

Exit code for failed executionThis indicates that the executed command failed, or the task itself failed for some other reason.

20

Failure

“Data Validation Error: <<Error Description>> “

Input fields validation error.

...

Anchor
Changelog
Changelog
Changelog

ue-cmd-1.0.0 (2024-10-31

...

)

Initial Release