Pipeline configuration and authoring
The Pipeline configuration and authoring domain tests whether you can turn repository intent into a valid, maintainable .gitlab-ci.yml: correct keyword placement, reusable includes and components, and pipeline-level controls. Expect questions on job structure, default, extends, !reference, include, and workflow:rules.
Core rules
- A job is any top-level key that is not reserved. It needs
scriptunless it is a trigger job or hidden template; hidden jobs start with.and never run. stagesdefines order; jobs in the same stage run in parallel..preand.postare reserved stages.defaultsupplies job defaults such asimage,services,cache,artifacts,before_script,after_script,retry,timeout,tags, andinterruptible; it does not define job-specificscript,stage, orrules.extendsperforms reverse deep merge for hashes; arrays are replaced, not concatenated. Use!referencewhen you need to reuse a specific list or hash.includecan pull local, remote, template, project, or CI/CD component YAML. Components declarespec:inputs, and callers passinputs.workflow:rulesdecides whether a pipeline is created at all; jobrulesonly decides whether a job is added.
Worked example
include:
- component: gitlab.com/acme/ci/[email protected]
inputs:
target: production
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
The component supplies a pinned build template. The workflow rules create MR pipelines, suppress branch pipelines when an MR is already open, and otherwise allow branch pipelines. Without the middle rule, a push to a branch with an open MR can create duplicate pipelines.
Traps
Mixing rules with legacy only/except is invalid. Assuming include arrays concatenate is wrong; later definitions can replace values. A hidden job with no script is fine, but a visible job without script fails validation unless it is a trigger. default does not apply to workflow. Reserved names such as image or stages cannot be used as job names.