GitLab FAQ Cheat Sheet for DevOps Interviews (2026)
Quick GitLab CI/CD FAQ cheat sheet: .gitlab-ci.yml, rules vs only/except, needs, runners, variables and security, checked against current GitLab docs.
GitLab interview FAQs keep returning to a short list: how .gitlab-ci.yml is structured, how rules decide when jobs run, how needs builds a DAG, how runners pick up jobs, and how variables and secrets are protected. This cheat sheet answers each of those in a few lines so you can revise the night before an interview.
This page is the quick-reference version. For the full question bank with longer answers, use the 90+ GitLab CI/CD interview questions post, and for worked pipelines see 15 GitLab CI/CD pipeline examples with YAML. Everything below was checked against the GitLab CI/CD YAML reference in November 2026.
Key takeaways
- A pipeline is defined in
.gitlab-ci.yml. The global keywords aredefault,include,stages,variablesandworkflow; everything else is a job keyword. - GitLab marks
onlyandexceptas deprecated. Interviewers expect you to userules. needslets a job start before its stage would normally run, which turns stages into a dependency graph.- Defining
image,services,cache,before_scriptorafter_scriptat the top level is deprecated; put them underdefault. - Runners execute jobs. Tags match jobs to runners, and executors (shell, Docker, Kubernetes and others) decide where the script runs.
- Protected and masked variables, plus protected branches and environments, are the first answers to any "how do you keep secrets safe" question.
Quick reference table
| Keyword or concept | One-line answer | Typical follow-up |
|---|---|---|
stages | Ordered list of stage names; jobs in one stage run in parallel by default. | What happens if a job has no stage? It goes to test. |
rules | Ordered conditions; the first matching rule decides whether and how the job is added. | Why not only/except? They are deprecated. |
workflow:rules | Decides whether the whole pipeline is created. | How do you stop duplicate branch and MR pipelines? |
needs | Starts a job as soon as the listed jobs finish. | Which artifacts can it download? Only from jobs in needs. |
include | Pulls in YAML from local, project, remote, template or component. | How many includes are allowed? Up to 150 per pipeline. |
extends | Reuses configuration from another job or hidden job. | Difference from YAML anchors? |
artifacts vs cache | Artifacts pass build output between jobs; cache speeds up dependency downloads. | Which one is guaranteed to be present? |
interruptible | Marks a job as safe to cancel when a newer pipeline starts. | How does auto-cancel use it? |
resource_group | Lets only one job in the group run at a time. | Why use it for deployments? |
Pipeline structure FAQs
1. What is .gitlab-ci.yml?
It is the YAML file at the root of a repository that defines the CI/CD pipeline. GitLab reads it on each push, merge request or scheduled run and creates a pipeline made of stages and jobs. You can split it across files with include, but there is always one entry file per project unless you change the CI/CD configuration path in project settings.
2. What is the difference between a stage and a job?
A job is the unit of work: a script that runs on a runner. A stage is a group label. Jobs in the same stage can run in parallel, and by default the next stage starts only when every job in the current stage has succeeded. If you add needs, a job can ignore that ordering and start as soon as its listed dependencies are done.
3. Which keywords are global and which belong to jobs?
The global keywords are default, include, stages, variables and workflow. Job keywords include script, image, services, rules, needs, artifacts, cache, environment, tags, retry, timeout, trigger and when, among others. Mixing the two up is a common slip in written tests.
4. What does the default keyword do?
default sets fallback values, such as image, retry or tags, for every job that does not set them itself. The default is not merged with a job's own value. If a job defines image, it uses its own image and ignores the default completely. Defaults also do not flow into downstream pipelines.
default:
image: python:3.12
retry: 1
stages: [build, test, deploy]
build:
stage: build
script:
- pip install -r requirements.txt
- python -m build
artifacts:
paths: [dist/]
unit-tests:
stage: test
script:
- pytest -q
5. Why is defining image or cache at the top level a problem?
GitLab's YAML reference lists globally defined image, services, cache, before_script and after_script as deprecated. They still work, but the supported way is to place them under default. Saying this in an interview shows you read current documentation instead of copying old examples.
Rules and workflow FAQs
6. How do rules work?
A job's rules list is evaluated in order. The first rule whose conditions match decides the outcome, for example when: on_success, when: manual or when: never. If no rule matches, the job is not added to the pipeline. Conditions can use if with CI/CD variables, changes for file paths and exists for files in the repository.
deploy-prod:
stage: deploy
script: ./deploy.sh production
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
- when: never
7. Are only and except still supported?
They still run, but GitLab's deprecated keywords page states that only and except are deprecated and recommends rules. The same page maps each form: only:refs and only:variables become rules:if, and only:changes becomes rules:changes. You also cannot mix rules with only or except in the same job.
8. What is workflow:rules used for?
Job-level rules control single jobs. workflow:rules decides whether the whole pipeline is created. If no workflow rule matches, no pipeline runs. A frequent use is avoiding duplicate pipelines, where a push to a branch with an open merge request would otherwise create both a branch pipeline and a merge request pipeline. Inside workflow:rules, when accepts only always or never.
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
9. How do you run a job only when certain files change?
Use rules:changes with a list of paths or glob patterns. It is also supported inside workflow:rules and include:rules. In a monorepo this is the standard way to build only the service whose folder changed. Be ready to mention that on a brand new branch or a scheduled pipeline there may be nothing to compare against, so test the behaviour before relying on it for production deploys.
Speed and dependency FAQs
10. What problem does needs solve?
Without needs, a test job for service B waits for every build job in the build stage, even the slow build for service A. With needs: [build-b], the test job starts as soon as build-b finishes. The pipeline becomes a directed acyclic graph rather than a strict stage-by-stage sequence, which usually shortens total run time.
11. What is the artifact rule when you use needs?
A job that uses needs can download artifacts only from the jobs listed in needs. GitLab's reference also says not to combine needs and dependencies in the same job. If you need artifacts from a job in the same stage, use needs:artifacts.
12. Artifacts or cache: which one should hold the compiled app?
Artifacts. They are uploaded to GitLab after the job and are passed to later jobs, so the deploy job is guaranteed to receive what the build job produced. Cache is a best-effort speed-up for things you can always download again, such as node_modules or a pip cache. If the cache is missing, the job should still work, only slower.
13. What does interruptible do?
It tells GitLab that a running job can be cancelled when a newer pipeline for the same ref makes it redundant. With auto-cancel set to on_new_commit: interruptible, only jobs marked interruptible: true are cancelled. Lint and test jobs are good candidates. Deploy jobs usually are not, because stopping them halfway can leave an environment in a mixed state.
14. How do you stop two deployments running at the same time?
Put the deploy jobs in the same resource_group. GitLab then runs only one job from that group at a time, and the others wait. This is the standard answer for "two merges landed within a minute and both tried to deploy to staging."
Reuse and templating FAQs
15. What are the include types?
GitLab supports include:local (a file in the same repository), include:project (a file in another project), include:remote (a URL), include:template (a GitLab-provided template) and include:component (a CI/CD component). Includes are evaluated first, and the reference allows up to 150 per pipeline.
16. extends or YAML anchors?
Both remove duplication. Anchors are plain YAML and only work inside one file. extends is a GitLab keyword, works across included files, and merges hashes in a way that is easier to read. Most teams use hidden jobs (names starting with a dot) plus extends for shared job templates.
.deploy-template:
image: alpine:3.20
before_script:
- apk add --no-cache curl
resource_group: deploy
deploy-staging:
extends: .deploy-template
stage: deploy
script: ./deploy.sh staging
environment: staging
17. What is a CI/CD component?
A component is a reusable, versioned unit of pipeline configuration that you pull in with include:component and configure with inputs. It is the newer way to share pipeline building blocks across many projects, instead of copying templates. Mention that inputs are declared in the component's spec header.
18. How do parent-child and multi-project pipelines differ?
Both use the trigger keyword. A parent-child pipeline runs a second pipeline in the same project, often generated for a monorepo folder. A multi-project pipeline triggers a pipeline in a different project, for example a deploy repository after the application build finishes.
Runner FAQs
19. What is a GitLab Runner?
GitLab Runner is the agent that picks up jobs from GitLab and runs them. Runners can be instance runners shared by every project, group runners, or project runners. GitLab.com also provides hosted runners. You install and register self-managed runners yourself.
20. What is an executor?
The executor decides how the runner runs a job. Common executors are shell (directly on the host), Docker (each job in a fresh container), and Kubernetes (each job in a pod). The Docker and Kubernetes executors give cleaner isolation, which is why they are the default choice for most teams.
21. How does a job get matched to a runner?
Through tags. A job with tags: [gpu] runs only on a runner that has the gpu tag. A runner can also be set to pick up untagged jobs. If no runner matches, the job stays pending, which is a classic troubleshooting question.
22. A job is stuck in pending. What do you check?
Check that a runner with matching tags exists and is online, that it is allowed to run jobs for this project, that a protected-branch job is going to a runner allowed to run protected jobs, and that the runner is not already at its concurrency limit. For more tuning ideas see 15 GitLab Runner optimization tips.
Variables and security FAQs
23. Where can CI/CD variables be defined?
In .gitlab-ci.yml (global or per job), in project, group or instance settings, and at run time for manual or scheduled pipelines. GitLab also provides predefined variables such as CI_COMMIT_BRANCH, CI_DEFAULT_BRANCH and CI_PIPELINE_SOURCE. Never put secrets in the YAML file itself because it is stored in Git.
24. What is the difference between protected and masked variables?
A protected variable is only passed to pipelines running on protected branches or protected tags. A masked variable is hidden in job logs. Production credentials usually need both. Masking alone does not stop a feature-branch pipeline from reading the value, which is why protection matters more.
25. What are protected environments?
They restrict who can deploy to an environment such as production. Combined with when: manual and deployment approvals on supported tiers, they give you a controlled release step. Our post on approval gates in CI/CD covers where those gates belong.
26. What is CI_JOB_TOKEN?
It is a short-lived token that GitLab creates for each job. A job can use it to call certain GitLab APIs, pull from the package or container registry, or clone allowed projects. It stops working when the job ends, which makes it safer than storing a personal access token in a variable.
27. How do you connect to a cloud provider without stored keys?
Use OpenID Connect. The id_tokens keyword creates a signed JWT for the job, and the cloud provider's identity federation trades it for short-lived credentials. That removes long-lived cloud keys from GitLab settings. The broader pattern is covered in securing CI/CD tokens.
Troubleshooting FAQs
28. The pipeline did not start at all. Why?
Usually workflow:rules matched nothing, the YAML has a syntax error, or the push was made with a skip-CI option. Open the pipeline editor, which validates the file and shows the merged configuration after includes.
29. A job ran on a merge request but not on the branch. Why?
The job's rules probably check $CI_PIPELINE_SOURCE == "merge_request_event". Branch pipelines have a different source, so the rule does not match. Print the variable in a debug job or read the rules top to bottom to find the first match.
30. Deploy failed because the build output was missing. What happened?
Common causes: the build job stored the output in cache instead of artifacts, the artifact expired, or the deploy job's needs list did not include the build job, so it could not download that job's artifacts.
How to use this cheat sheet
Read the table first and try to answer each follow-up out loud. Then write a small pipeline from memory with workflow:rules, needs, extends and a protected deploy job, and run it in a free GitLab project. Interviewers often ask you to explain a pipeline you wrote, so a working example on your own account helps more than memorised definitions. When you want longer drills, move on to the scenario-based GitLab CI/CD questions, and use the 200+ DevOps interview questions hub to cover the rest of the toolchain.
If you want guided practice on real pipelines, our GitLab training runs as a classroom batch in Kharadi, Pune, and as live online classes for learners in other cities.
FAQ
Is GitLab CI/CD free to use?
GitLab has a Free tier that includes CI/CD. Some features, such as certain approval and compliance controls, are limited to Premium or Ultimate. Check GitLab's pricing page for the current split.
Should I still learn only and except?
Know what they do so you can read old pipelines, but write new configuration with rules. GitLab's documentation marks only and except as deprecated.
What is the fastest way to speed up a slow GitLab pipeline?
Add needs so jobs do not wait for whole stages, cache dependencies, use rules:changes to skip unaffected jobs, and mark safe jobs interruptible.
What is the difference between a runner and an executor?
The runner is the agent program that talks to GitLab and takes jobs. The executor is the method it uses to run each job, such as shell, Docker or Kubernetes.
How do I keep secrets out of job logs?
Store them as masked and protected CI/CD variables, never echo them, and prefer OIDC with id_tokens for cloud access so there are no long-lived keys to leak.
Is there an official GitLab certification?
Certification facts should come only from GitLab's own website, so check there for current exams before you book anything. See our GitLab certification prep post for topic coverage.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0