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.


...