CICD-017 · Define a job dependency
Encyclopedia · Jobs, steps and runner selection · All snippets
Previous · CICD-016 · Next · CICD-018
1. Where it fits
- Placement Inside the downstream job under
jobs.<job_id>in the workflow file. - Prerequisites workflow containing the named example jobs or steps.
- Platforms github-actions, gitea-actions.
2. Copy the snippet
yaml
needs: [lint, test]3. How it works
needs declares dependencies on the job IDs lint and test. The downstream job waits for both and can inspect their results and declared outputs.
Both checks must settle before their dependent job can run.
flowchart TD
N1["Lint"]
N2{"Both checks pass"}
N1 --> N2
N3["Test"]
N3 --> N2
N4["Downstream job"]
N2 -->|Yes| N4
N5["Downstream blocked"]
N2 -->|No| N5
4. Verify the result
Add to the build job. It starts after both upstream jobs succeed.
Validation syntax-validated (YAML parse). Status definitions.