Skip to content

Commit b636bd4

Browse files
committed
Merge pull request #1399 from amanchopra1905/stage
global Pre and global Post commands
1 parent 7e54102 commit b636bd4

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

docs/deep-dive-into-hyperexecute-yaml.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,72 @@ The uploadArtefact flag is not currently supported for tests running with the **
617617

618618
***
619619

620+
### `globalPre`
621+
> Currently, only **Linux OS** is supported
622+
623+
The `globalPre` flag allows you to define a pre-execution step that runs once before any task starts. This flag ensures that all necessary setup tasks, such as installing dependencies, configuring environments, or initializing resources, are completed before test execution begins.
624+
625+
#### Functionality
626+
- Runs before any test execution starts, ensuring the environment is properly configured.
627+
- Executed on a separate machine (VM) or the local machine, based on the [test discovery mode](/support/docs/deep-dive-into-hyperexecute-yaml/#mode) selected.
628+
- Useful for setup tasks, such as fetching credentials, initializing databases, or downloading required files.
629+
630+
```yaml title="hyperexecute.yaml"
631+
globalPre:
632+
mode: remote #local or remote
633+
commands:
634+
- "echo 'Setting up environment'"
635+
- "apt-get update && apt-get install -y curl"
636+
- "curl -X POST https://api.example.com/init"
637+
```
638+
639+
#### Parameters
640+
| Parameter | Type | Description |
641+
|-----------|------|-------------|
642+
| mode | string | Defines where the pre-step commands will be executed. Options: local or remote. |
643+
| commands | list | List of shell commands to execute before test execution begins. |
644+
645+
***
646+
647+
### `globalPost`
648+
> Currently, only **Linux OS** is supported
649+
650+
The `globalPost` flag defines a post-execution step that runs once after all tasks have completed. This step ensures that cleanup tasks, such as removing temporary files, logging results, or notifying external systems, are performed after test execution.
651+
652+
#### Functionality
653+
- Runs after all test execution is completed, ensuring final cleanup and reporting.
654+
- Executed on a separate machine (VM) or the local machine, based on the mode selected.
655+
- Useful for cleanup tasks, such as deleting test artifacts, summarizing reports, or deallocating cloud resources.
656+
657+
```yaml title="hyperexecute.yaml"
658+
globalPost:
659+
mode: remote #local or remote
660+
commands:
661+
- "echo 'Cleaning up test environment'"
662+
- "rm -rf /tmp/test-results"
663+
- "curl -X POST https://api.example.com/cleanup"
664+
```
665+
666+
#### Parameters
667+
| Parameter | Type | Description |
668+
|-----------|------|-------------|
669+
| mode | string | Defines where the post-step commands will be executed. Options: local or remote. |
670+
| commands | list | List of shell commands to execute after test execution completes. |
671+
672+
#### Difference between `globalPre`/`globalPost` and `pre`/`post` flags
673+
| Scenario | globalPre | globalPost | pre | post |
674+
|----------|-----------|------------|-----|------|
675+
|Execution Scope | Runs once before all tasks | Runs once after all tasks | Runs before each individual task | Runs after each individual task |
676+
|Execution Frequency | Executes once per entire test execution | Executes once after all tasks complete | Executes once per task | Executes once per task |
677+
|Execution Location | Separate VM or local machine | Separate VM or local machine | Inside the task environment | Inside the task environment |
678+
|Purpose | Global setup (e.g., install dependencies, initialize environment) | Global cleanup (e.g., remove logs, finalize reports) | Task-specific setup (e.g., prepare test data) | Task-specific cleanup (e.g., delete temporary files) |
679+
|Isolation | Runs in a dedicated VM (if remote) | Runs in a dedicated VM (if remote) | Runs in the same task environment | Runs in the same task environment |
680+
|Configuration Placement | Defined globally in the YAML configuration | Defined globally in the YAML configuration | Defined within the task block | Defined within the task block|
681+
|Typical Commands | Install dependencies, start services | Cleanup logs, send reports | Load test-specific configs, set environment variables | Delete temp files, reset configurations
682+
|Example Usage | `apt-get update`, `docker pull` | `rm -rf /logs`, `curl -X POST …` | `export ENV=staging` | `rm -rf temp/*` |
683+
684+
***
685+
620686
### `captureScreenRecordingForScenarios`
621687
If this key is set to true, it will record whole scenario execution, and then video is accessible from your HyperExecute dashboard.
622688
This can be majorly used for non selenium based tests to have the recorded video of the whole scenario.

docs/hyperexecute-yaml-parameters.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ The **HyperExecute YAML** file serves as the foundational component for test exe
131131

132132
| Key | Type | Description|
133133
|-----|------|------------|
134+
| [globalPre](/support/docs/deep-dive-into-hyperexecute-yaml/#globalpre) | Map | This flag runs once before all tasks start, used for global setup such as installing dependencies or configuring environments. |
135+
| [globalPost](/support/docs/deep-dive-into-hyperexecute-yaml/#globalpost) | Map | This flag runs once after all tasks finish, used for global cleanup such as removing logs or finalizing reports. |
134136
| [failFast](/support/docs/deep-dive-into-hyperexecute-yaml/#failfast) | Map | Flag to fail a job faster if there are `x` consecutive failures. |
135137
| [differentialUpload](/support/docs/deep-dive-into-hyperexecute-yaml/#differentialupload) | Map | Minimize the time of upload of code. |
136138
| [background](/support/docs/deep-dive-into-hyperexecute-yaml/#background) | Map |It is used to trigger long-running Application Servers tasks like running WebApps or databases |

0 commit comments

Comments
 (0)