Execute script

Overview of the Execute script job step, which allows for executing shell scripts.

Figure 1. Execute script job step

The Execute script job step makes it possible to run shell scripts during a job. From the job step settings (Figure 1), you can customize information about the job step, including:

  • A custom step name can be defined; otherwise, the default step name will be used
  • Execution type: This can be a Shell script or a batch command.
  • Job execution: Enter the Execution command which should be executed. Next to the Job execution field, button enables text wrapping of the commands entered in the field.
  • Every step has Advanced options through which steps can be managed. When execution of the step fails, execution of the job continues. If option Abort job on step fail is marked, Job execution will stop once this step fails and further steps will not be executed. When it comes to skip condition, it allows skipping the current step if the condition is met.
    Figure 2. Execute script job step with advanced options shown
Note: In order to save a form, all input fields must be valid. Required fields are signed with *.
Note: When script finishes its execution, it will result with a status code. This code is an integer value that represents a response from the OS that reports success, an error or another condition that provides a clue about what caused an unexpected result from the executed command or script. For example, if the script finishes successfully OS will result with status code 0, which means that your command/script has executed and exited without any problems or errors.
Note: When using a Windows batch script, if an error occurs, the script will not stop its execution; it will finish, and the status will be passed. This is a standard behavior because batch files do not terminate automatically if a command fails with an error (inherited from MS-DOS). They do terminate if there is a syntax error within the file. If you need to check the behavior of a specific command, you can add the following code after the line you expect to fail to inspect the behavior of the error.
IF %ERRORLEVEL% NEQ 0 ( 
    EXIT /b 1
)
Note: Please note that only one typhoon-python command can be executed per job execution step with Windows Batch script. If you need to execute more than one typhoon-python command, you can add multiple execution steps to the job definition. Alternatively, you can use the call batch command, as shown in the code snippet below, which allows calling typhoon-python multiple times within the same execution step.
call typhoon-python -m pytest "tests/demo_tests" 
From inside a script, it is possible to update notes or tags of an execution. Following command updates execution notes:
update-tth-execution --notes execution_id "new notes value"
Execution tags can be updated with following command (tags should be a single string joined with commas):
update-tth-execution --tags execution_id "first tag, second tag"
Additionally, report notes can also be modified from the script. Following command updates report notes:
update-tth-report --notes report_id "new notes value"