skip to content

CI/CD Pipelines

GitLab CI/CD seen from the project rather than from the YAML: where the pipeline configuration is read from, the settings that cancel redundant runs and decide who sees a pipeline, schedules that run as their owner, merge trains, and the job token a job uses to reach other projects. Interviewers start here before they read a line of .gitlab-ci.yml.

on this pageshow

explore

questions

6

In GitLab, where does a project's pipeline configuration come from, and what runs when the repository has no .gitlab-ci.yml?

level: juniorimportance: must knowfreq 46%

answer

  1. the repository root, by default
  2. one project setting can move it
  3. path@group/project or a .yml URL
  4. no file: Auto DevOps, maybe
  5. needs a Dockerfile or buildpack

basics

~20 s

GitLab reads .gitlab-ci.yml from the repository root unless the project's CI/CD configuration file setting names another path, another project's file or a .yml URL. With no file, only Auto DevOps can run, if enabled and it finds a Dockerfile or buildpack.

solid answer

~50 s

By default GitLab looks for `.gitlab-ci.yml` in the root of the repository at the commit being built. The project's **CI/CD configuration file** setting (under the general pipeline settings) can point elsewhere: a path relative to the root such as `ci/pipeline.yml`, a file in another project written `path@group/project` (read from that project's default branch unless you append `:refname`), or a full URL that ends in `.yml`. Jobs see the chosen path in `CI_CONFIG_PATH`. When the project has no configuration file at all, nothing runs unless Auto DevOps is on — through **Default to Auto DevOps pipeline** on the project, inherited from its group, or switched on for every project by an instance administrator — and Auto DevOps only runs automatically when it finds a `Dockerfile` or a matching buildpack. A real `.gitlab-ci.yml` always takes precedence over Auto DevOps.

go deeper

for a junior

Know that GitLab reads .gitlab-ci.yml from the repository root by default, and that a project can have no pipeline at all if that file is missing.

for a middle

Explain the three forms the CI/CD configuration file setting accepts, how CI_CONFIG_PATH reports the choice, and the exact conditions under which Auto DevOps runs instead.

for a senior

Show you can find where an inherited project's pipeline really comes from — moved file, another project, external URL, inherited Auto DevOps — and weigh the trust cost of each source.

for a principal

Discuss when separating pipeline ownership from code ownership is worth the friction, and why moving the file is not the same as enforcing jobs across an organisation.

## The default: a file in the repository A GitLab **pipeline** is created from a **CI/CD configuration file**, a YAML document that lists the jobs to run. Unless someone changes a setting, GitLab looks for a file named `.gitlab-ci.yml` in the **root directory** of the repository, at the exact commit the pipeline is for. That has two useful consequences: - The configuration is **versioned with the code**: a branch that changes the build also changes the pipeline that tests it. - A branch can change its own pipeline, and the change is tested on that branch before it reaches the default branch. The predefined variable `CI_CONFIG_PATH` tells a running job which path was used; it defaults to `.gitlab-ci.yml`. What the file may contain (jobs, stages, `include:` of other files and so on) is a separate subject, covered with the GitLab CI keywords; this answer is about where GitLab reads it from. ## Moving the file: the CI/CD configuration file setting Each project has a **CI/CD configuration file** field in its general pipeline settings. It accepts three forms: | Form | Example | Read from | |---|---|---| | Path in this repository | `my/path/.my-custom-file.yml` | this project, relative to the root | | File in another project | `.gitlab-ci.yml@acme/ci-config` | that project's default branch, or `...@acme/ci-config:refname` | | External file | `https://config.example.com/generate/ci/config.yml` | the URL, which must end in `.yml` | Teams usually move the file for one of two reasons: 1. **A tidier repository** — the configuration lives under a `ci/` folder with its helpers. 2. **Separating who may edit the pipeline from who may edit the code** — the file sits in a separate project where only a few people have write access, while other projects can read it but not change it. The second pattern has costs. The project's **pipeline editor** cannot edit a configuration file that lives in another project or on an external site, so changes go through the other project's own review. An external URL means the pipeline definition is fetched from outside GitLab at pipeline creation, so whoever controls that URL controls what your jobs run. And the setting itself belongs to the project: it moves the file, it does not on its own stop the project from being pointed elsewhere. Forcing jobs into every project's pipeline is a different mechanism, covered with GitLab CI templates and policies. ## When there is no file: Auto DevOps **Auto DevOps** is GitLab's ready-made pipeline that detects the language, builds, tests, scans and can deploy. It only matters when a project has **no** configuration file: - It is switched on with **Default to Auto DevOps pipeline**, per project (Maintainer or Owner), per group (Owner; subgroups and projects inherit it and can opt out), or for every project on an instance with **Default to Auto DevOps pipeline for all projects** (an administrator setting). - It **runs automatically only if** the repository has a `Dockerfile` or code that matches a buildpack. - If a `.gitlab-ci.yml` exists, **your configuration takes precedence** and the Auto DevOps pipeline does not run. - Without deployment preparation (a base domain and a deployment target), it can build and test but cannot deploy. - GitLab can **switch Auto DevOps off** for a project on its own. The documented causes are that the setting was only inherited from a group or the instance rather than enabled in the project, that the project has no successful Auto DevOps pipelines, and that an Auto DevOps pipeline failed. Enabling it in the project itself and fixing the failing pipeline is the remedy. A project that wants Auto DevOps plus its own jobs writes a `.gitlab-ci.yml` that includes the Auto DevOps template; at that point it is an ordinary configuration file and the setting no longer decides anything. ## When nothing runs at all Two situations leave a project with no pipelines: - **No configuration file and no Auto DevOps** (or Auto DevOps on but nothing it can detect). - **CI/CD turned off** for the project in its visibility and feature settings. The CI/CD menu, the pipelines and jobs pages disappear; existing pipelines are hidden, not deleted, and come back if CI/CD is turned on again. ## Reading a project you have just inherited When you take over a set of projects, the quickest audit is: does each one have a root `.gitlab-ci.yml`, does its **CI/CD configuration file** setting point somewhere else, and is Auto DevOps enabled on the project, a parent group or the instance? A pipeline nobody can find in the repository usually comes from one of the last two.

  • In GitLab, what changes for a project's developers when its CI/CD configuration file lives in a separate project?
    They can no longer change the pipeline from their own repository or its pipeline editor; edits go through the configuration project, with its own write permissions and review. GitLab reads the file from that project's default branch unless the setting appends `:refname`, so a change there affects every pipeline that points at it from then on.
  • In GitLab, can a project use Auto DevOps and its own .gitlab-ci.yml together?
    Yes, but only by making Auto DevOps part of its own file: the project's `.gitlab-ci.yml` includes the `Auto-DevOps.gitlab-ci.yml` template and adds or overrides jobs. The **Default to Auto DevOps pipeline** setting only decides what happens when there is no configuration file, so once the file exists the setting has no effect.

  • GitLab runs any YAML file it finds anywhere in the repository.
  • The configuration file must always be .gitlab-ci.yml in the repository root.
  • Auto DevOps runs alongside a project's own .gitlab-ci.yml pipeline.
  • Auto DevOps builds any project, even with no Dockerfile or matching buildpack.
  • Turning off CI/CD for a project deletes its existing pipelines.
open as a page

In GitLab, a job in one project gets 404 Not Found using CI_JOB_TOKEN against another private project; what decides whether that call is allowed?

level: middleimportance: must knowfreq 36%

basics

~20 s

A CI_JOB_TOKEN call into another GitLab project succeeds only if the target project's job token allowlist names the calling project or its group, the user who started the job has enough access in the target, and the endpoint accepts job tokens.

open as a page

In GitLab, Auto-cancel redundant pipelines is enabled, yet older pipelines on a busy branch keep running after new pushes; why?

level: middleimportance: should knowfreq 29%

basics

~20 s

The setting cancels older pipelines when a newer commit's pipeline starts on the same branch, but by default a running pipeline is spared once any job not marked interruptible has started. Jobs default to non-interruptible, so most running pipelines survive.

open as a page

In GitLab, why does a nightly pipeline schedule turn Inactive after its owner leaves the project, and what does Take ownership change?

level: middleimportance: should knowfreq 27%

basics

~20 s

A GitLab pipeline schedule runs with its owner's permissions, so when the owner is blocked or removed from the project it turns Inactive. A Maintainer or Owner who selects Take ownership reactivates it, and it then runs with their permissions.

open as a page

In GitLab, why can two merge requests that each passed a merged results pipeline still break main, and how does a merge train prevent that?

level: seniorimportance: should knowfreq 15%

basics

~20 s

A merged results pipeline tests one merge request combined with the current target branch, not with others merging at the same time. A merge train queues merge requests and tests each against the target plus every request ahead, merging in order.

open as a page

In GitLab, who can read the job logs and artifacts of a public project's pipelines, and which settings narrow that?

level: middleimportance: nice to knowfreq 17%

basics

~20 s

On a public GitLab project with Project-based pipeline visibility selected and CI/CD open to Everyone With Access, anyone can read pipelines, job logs and artifacts. Clearing that checkbox, or setting CI/CD to Only project members, keeps them to project members.

open as a page