Replace the default stage-based ordering by adding needs: to jobs that should run as soon as their dependencies complete, regardless of stage: job-b: stage: test; needs: [job-a] — job-b starts immediately after job-a succeeds without waiting for all stage: build jobs
To receive artifacts from a dependency, specify needs with artifacts: true: needs: [{job: build-frontend, artifacts: true}] so the artifacts from that specific job are downloaded before the dependent job starts
For jobs that should run without any dependency (i.e., immediately at pipeline start), set needs: [] explicitly — without this, a job in a later stage waits for all prior-stage jobs even if they are unrelated
Model a fan-out/fan-in pattern: one build job produces an artifact, multiple parallel test jobs declare needs: [build] with artifacts: true, and a final report job declares needs over all test job names
Validate the DAG structure with the GitLab CI Lint tool (Repository > CI/CD > CI Lint or API endpoint /api/v4/ci/lint) which visualizes the job dependency graph
Set rules: with if: $CI_PIPELINE_SOURCE to conditionally include or exclude branches of the DAG without restructuring the entire pipeline YAML
Known gotchas
A job can only specify needs: entries from earlier stages or jobs in the same stage; specifying a job in a later stage in needs: causes a validation error — the DAG must remain acyclic and forward-referencing only
If a job listed in needs: is excluded from the pipeline by rules:, the dependent job is also excluded unless you add needs: [{job: excluded-job, optional: true}] to handle optional dependencies
Artifact size from a needs: job counts against the pipeline artifact quota; in large fan-out pipelines with many parallel jobs each downloading the same large artifact, storage and transfer costs accumulate — consider using a cache or a registry for large build artifacts instead of pipeline artifacts
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp