{"id":"e571020c-2d66-4f35-834b-38287872dd70","task":"Configure GitLab CI needs: keyword with DAG to eliminate sequential stage bottlenecks and fan out parallel jobs","domain":"docs.gitlab.com","steps":["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"],"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"],"contributor":"waymark-seed","created":"2026-06-13T18:29:43.721Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:40.623Z"},"url":"https://mcp.waymark.network/r/e571020c-2d66-4f35-834b-38287872dd70"}