Commit 88d4c44
authored
Auto-detect pipeline ID and commit SHA for local e2e test runs (#47575)
### What does this PR do?
When running `dda inv new-e2e-tests.run` locally (not in CI), automatically look up the most recent GitLab pipeline for the current HEAD commit SHA and set `E2E_PIPELINE_ID` / `E2E_COMMIT_SHA` — so tests use the correct build artifacts without needing the user to set those env vars manually.
Two changes in `tasks/new_e2e_tests.py`:
**New helper `_find_pipeline_for_commit_sha`**
- Queries the GitLab API for pipelines matching the current HEAD commit SHA
- For each candidate pipeline, fetches all jobs and verifies that the `packaging` and `deploy_packages` stages are both present and have all jobs in `success` or `skipped` state
- Returns the first pipeline that passes, or `None` with a diagnostic message to stderr
**Updated `run` task (local path only)**
- Inside the existing `if not running_in_ci():` block, if `E2E_PIPELINE_ID` is not already in the environment, calls the new helper and sets `E2E_PIPELINE_ID` + `E2E_COMMIT_SHA` in `env_vars`
- If no qualifying pipeline is found, prints a yellow warning and continues — the task still runs, preserving previous behaviour for cases where no pipeline exists (e.g. a brand-new branch)
### Motivation
Previously, developers had to manually find the right pipeline ID and set `E2E_PIPELINE_ID`/`E2E_COMMIT_SHA` before running e2e tests locally. This was error-prone and tedious. The auto-detection removes that friction while ensuring only pipelines with completed packaging artifacts are used.
### Describe how you validated your changes
- Code review: verified the GitLab `pipelines.list(sha=...)` and `pipeline.jobs.list(get_all=True)` API usage matches the python-gitlab client interface already used elsewhere in the codebase (`_find_recent_successful_pipeline`)
- The change is gated behind `not running_in_ci()` and `"E2E_PIPELINE_ID" not in os.environ`, so it is a no-op in CI and when users have already set the env var manually
- Tried on this branch, with unready pipeline I had the following message, continued with default behavior
```
Pipeline 101237294 skipped: jobs not passed: packaging/agent_suse-arm64-a7-fips (running), packaging/agent_rpm-arm64-a7-fips (running), packaging/agent_suse-arm64-a7 (running), packaging/agent_rpm-arm64-a7 (running), packaging/agent_oci (created), packaging/agent_deb-arm64-a7-fips (running), packaging/agent_deb-arm64-a7 (running), deploy_packages/deploy_ddot_oci (manual), deploy_packages/deploy_installer_oci (manual), deploy_packages/deploy_agent_oci (created), deploy_packages/qa_installer_script_linux (manual)
No pipeline with passing packaging and deploy_packages stages found for commit 1dfa6245, skipping pipeline auto-detection
```
Once the pipeline is ready, got
```
Pipeline ID: 101251448
```
### Additional Notes
- Requires a `GITLAB_TOKEN` env var with `read_api` scope for the GitLab API calls; if absent, a warning is printed and the task continues without auto-detection
- `skipped` jobs are counted as passing (rules may exclude certain platforms/architectures)
Co-authored-by: paola.ducolin <[email protected]>1 parent a09fc4d commit 88d4c44
1 file changed
+87
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
334 | 361 | | |
335 | 362 | | |
336 | 363 | | |
| |||
1168 | 1195 | | |
1169 | 1196 | | |
1170 | 1197 | | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
1171 | 1258 | | |
1172 | 1259 | | |
1173 | 1260 | | |
| |||
0 commit comments