90+ GitLab CI/CD Interview Questions and Answers (2027)

101 GitLab CI/CD interview questions with answers for freshers, 2-5 years and seniors: rules, needs, include, cache, artifacts, runners, components.

Sep 17, 2025 - 14:13
Nov 7, 2026 - 05:16
 0  378
90+ GitLab CI/CD Interview Questions and Answers (2027)

GitLab CI/CD interview questions check whether you can write and debug a .gitlab-ci.yml file, run jobs on GitLab Runner, control when jobs run with rules and workflow, move data between jobs with artifacts and cache, deploy safely through environments, and keep pipelines fast and secure as a project grows. This page has 101 numbered questions with direct answers, grouped by experience level and followed by real troubleshooting scenarios.

Every keyword and default below was checked against the CI/CD YAML syntax reference on docs.gitlab.com in November 2026. Where a feature needs a paid tier (Premium or Ultimate), the answer says so, because interviewers often ask what works on the Free tier.

Key takeaways

  • Freshers are asked about pipelines, stages, jobs, runners, variables, artifacts, cache and the difference between rules and the deprecated only/except keywords.
  • Candidates with 2 to 5 years of experience should explain needs, workflow:rules, include, parent-child and multi-project pipelines, parallel:matrix, environments and resource_group without notes.
  • Senior candidates are tested on CI/CD components and the CI/CD Catalog, spec:inputs, merge trains, pipeline execution policies, OIDC with id_tokens and runner fleet design.
  • New runners are registered with a runner authentication token that starts with glrt-. The old registration token workflow is disabled by default since GitLab 17.0.
  • For downstream pipelines, trigger:strategy: mirror (GitLab 18.2 and later) is now the recommended option; depend is documented as not recommended.
  • Scenario answers carry the most weight for experienced roles. Practise explaining the symptom, how you would confirm the cause, the fix, and how you would stop it happening again.

How to use this guide

Each answer starts with a sentence you could say in an interview, then adds the detail an interviewer is likely to ask about next. If you want working pipelines to study alongside these answers, read our 15 GitLab CI/CD pipeline examples with YAML. This page focuses on the concepts and reasoning that interviews test.

Your experienceRead firstThen practise
Fresher or career switcherQuestions 1 to 32A three-stage pipeline (build, test, deploy) on a project runner you registered yourself
2 to 5 yearsQuestions 33 to 67Merge request pipelines with workflow:rules, needs, a review app and a parent-child pipeline
Senior, lead or platform engineerQuestions 68 to 87Publish a CI/CD component with inputs, set up OIDC to a cloud account, design a runner fleet
Everyone with work experienceQuestions 88 to 101 (scenarios)Explain each scenario aloud in under two minutes

Other posts in this series cover narrower angles: scenario-based GitLab CI/CD questions, advanced GitLab questions and GitLab CI/CD basics for freshers.

GitLab CI/CD interview questions for freshers

1. What is GitLab CI/CD?

GitLab CI/CD is the continuous integration and delivery system built into GitLab. You describe the pipeline in a YAML file in the repository, and GitLab creates a pipeline for events such as a push, a merge request, a tag or a schedule. GitLab Runner picks up the jobs and runs them. Because the code, merge requests, pipelines, container registry and environments live in one product, you do not need a separate CI server or plugins to connect them.

2. What is the .gitlab-ci.yml file and where does it go?

It is the pipeline configuration file. By default it sits in the root of the repository and is named .gitlab-ci.yml. A Maintainer can point the project at a different path or file in the CI/CD settings, which some teams use to keep pipeline files in a central project. The file is versioned with the code, so a change to the pipeline goes through the same review as a change to the application.

3. What are pipelines, stages and jobs?

A job is the smallest unit: a set of commands that runs on a runner and passes or fails. A stage is a group of jobs. A pipeline is the full set of jobs and stages created for one event. Jobs in the same stage can run at the same time, and by default a stage starts only after every job in the previous stage succeeds.

stages:
  - build
  - test
  - deploy

build-app:
  stage: build
  script:
    - make build

unit-tests:
  stage: test
  script:
    - make test

deploy-prod:
  stage: deploy
  script:
    - ./deploy.sh

4. What are the default stages, and what happens to a job with no stage?

If you do not define stages, GitLab uses .pre, build, test, deploy and .post. A job without a stage keyword goes into test. The .pre stage always runs first and .post always runs last, whatever order you list the other stages in. A pipeline that contains only .pre and .post jobs does not run.

5. How do jobs inside one stage run?

They run in parallel, limited only by how many runners are free and how many jobs each runner is allowed to run at once. The next stage waits until all jobs in the current stage finish successfully, unless a job uses needs to start earlier (see question 33).

6. What is GitLab Runner?

GitLab Runner is the agent that executes jobs. It polls GitLab for work, receives a job, prepares an environment with the chosen executor, clones the repository, runs the script and sends the log, status, artifacts and cache back. You can use the runners GitLab hosts on GitLab.com or install your own on Linux, Windows, macOS or Kubernetes.

7. What is the difference between instance, group and project runners?

Runner typeAvailable toTypical use
Instance runnerEvery project on the GitLab instanceGeneral build capacity managed by the platform team
Group runnerAll projects and subgroups in one groupA team or business unit with shared needs
Project runnerThe projects it is assigned toSpecial hardware, network access to a private system, or isolation for production deploys

8. What is an executor, and which ones exist?

The executor decides how the runner creates the environment for each job. The executors page lists Docker, Docker Autoscaler, Instance and Kubernetes as actively developed. SSH, Shell, Parallels, VirtualBox and Custom are in maintenance mode, which means security fixes only. Docker Machine is deprecated. Most teams start with Docker or Kubernetes because each job gets a clean container.

9. How do you register a new runner today?

You create the runner first, in the GitLab UI or with the POST /user/runners API, and set its tags and options there. GitLab gives you a runner authentication token that starts with glrt-. You then run gitlab-runner register with that token. Since GitLab 17.0 the older registration token workflow is disabled by default, and register returns 410 Gone if someone tries it without an admin turning it back on.

gitlab-runner register \
  --non-interactive \
  --url "https://gitlab.com/" \
  --token "$RUNNER_AUTHENTICATION_TOKEN" \
  --executor "docker" \
  --docker-image "alpine:latest"

10. What do tags on a job do?

Tags select which runners can pick up a job. A runner must have every tag listed on the job. Tags are case sensitive and a job can list up to 50. An empty tags list removes tags inherited from default, so only runners that accept untagged jobs can run it.

11. What are script, before_script and after_script?

script holds the main commands and is required for every job except trigger jobs. before_script runs before script in the same shell, so exported variables carry over. after_script runs afterwards in a new shell with its own timeout (5 minutes by default). It still runs when the job fails or is cancelled, which makes it the place for cleanup, but it cannot change the job's exit code.

12. What do image and services do?

image is the container image the job runs in when you use the Docker or Kubernetes executor. services starts extra containers next to it, such as a database for integration tests, reachable by a hostname derived from the image name or an alias.

integration-tests:
  image: python:3.13
  services:
    - name: postgres:17
      alias: db
  variables:
    POSTGRES_PASSWORD: example
    DATABASE_URL: "postgresql://postgres:example@db:5432/postgres"
  script:
    - pip install -r requirements.txt
    - pytest tests/integration

13. What is the default keyword?

default sets values that every job gets unless the job defines its own. Common choices are image, before_script, cache, retry, interruptible and tags. A job value replaces the default value rather than merging with it. Setting image, services, cache, before_script or after_script at the top level of the file, outside default, is deprecated.

14. How do you define variables in .gitlab-ci.yml?

Use the variables keyword at the top level (default for all jobs) or inside a job. A top-level variable can also have a description, value and options, which turn it into a prefilled form field when someone runs the pipeline manually.

variables:
  DEPLOY_ENV:
    value: "staging"
    options:
      - "staging"
      - "production"
    description: "Where to deploy when running this pipeline manually"

build:
  variables:
    NODE_ENV: production
  script:
    - npm ci
    - npm run build

15. Name some predefined variables you use often.

  • CI_COMMIT_SHA and CI_COMMIT_SHORT_SHA: the commit being built, useful for image tags.
  • CI_COMMIT_BRANCH and CI_COMMIT_TAG: set for branch and tag pipelines respectively.
  • CI_DEFAULT_BRANCH: the project's default branch, so you do not hardcode main.
  • CI_PIPELINE_SOURCE: what created the pipeline, such as push, merge_request_event, schedule or web.
  • CI_PROJECT_DIR: where the repository is cloned on the runner.
  • CI_REGISTRY, CI_REGISTRY_IMAGE, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD: for pushing to the project's container registry.

16. Where should secrets go?

Never in .gitlab-ci.yml. Store them as project or group CI/CD variables in the settings, marked masked so they are replaced with [MASKED] in logs, and protected if only pipelines on protected branches or tags should see them. For long-lived production credentials, a better choice is an external secrets manager through the secrets keyword or short-lived cloud credentials through id_tokens (questions 75 and 76).

17. What are artifacts?

Artifacts are files a job uploads to GitLab when it finishes, such as a compiled binary, a test report or a built website. Later jobs in the pipeline can download them, and people can download them from the UI. Paths are relative to the project directory.

build:
  stage: build
  script:
    - make build
  artifacts:
    paths:
      - dist/
    expire_in: 1 week

18. What is the cache?

The cache stores files such as downloaded dependencies so later pipelines can reuse them instead of fetching them again. It is a speed optimisation and is not guaranteed to exist: a job must still work if the cache is empty. The cache lives on the runner or in a shared object store that the runner is configured to use.

19. What is the difference between cache and artifacts?

AspectCacheArtifacts
PurposeSpeed up jobs by reusing dependenciesPass build outputs between jobs and keep results
StoredOn the runner or the runner's shared cache storageIn GitLab
Guaranteed to be thereNoYes, until they expire
Shared across pipelinesYes, by cache keyMainly within one pipeline (or by API)
Typical contentnode_modules, .m2, pip cacheBinaries, test reports, coverage, built sites

20. What values can when take?

on_success (the default) runs the job only if no earlier-stage job failed. on_failure runs it only if one did. always runs it regardless. manual adds a job that someone must start. delayed runs it after start_in. never stops the job from being added and is only valid inside rules or workflow:rules.

21. What does allow_failure do, and what are its defaults?

A job with allow_failure: true can fail without failing the pipeline; it shows an orange warning. The default is false for normal jobs, true for a job with when: manual at job level, and false for when: manual set inside rules. You can also limit it to specific exit codes with allow_failure:exit_codes.

22. What is a manual job, and how do you add a confirmation prompt?

A manual job has when: manual and waits for someone with permission to click run. It is common for production deploys. manual_confirmation (GitLab 17.1 and later) adds a custom message the user must confirm before the job starts.

deploy-prod:
  stage: deploy
  script: ./deploy.sh production
  when: manual
  manual_confirmation: "Deploy to production? Check the release notes first."

23. How do rules work?

rules is a list of conditions evaluated in order. The first rule that matches decides whether the job is added and with which when, allow_failure, variables or needs. If no rule matches, the job is not added to the pipeline. Each rule can use if (a variable expression), changes (files changed), exists (files present) and when.

24. Why use rules instead of only and except?

The deprecated keywords page states that only and except are deprecated. They still work for backward compatibility but could be removed in a future major release. rules is more expressive (you can combine branch, source, file changes and variables in one condition) and you cannot mix rules with only/except in the same job.

25. How do you run a job only on the default branch?

publish:
  script: ./publish.sh
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

Comparing with CI_DEFAULT_BRANCH keeps the file working if the project renames master to main or anything else.

26. How do you run a job only in merge request pipelines?

lint:
  script: npm run lint
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

merge_request_event is also the value used by merged results and merge train pipelines.

27. What pipeline types does GitLab create?

Branch pipelines run on pushes to a branch. Tag pipelines run when a tag is pushed. Merge request pipelines run on the merge request's source branch. Merged results pipelines test the result of merging the source into the target. Merge train pipelines test a queue of merge requests together. Scheduled pipelines run on a cron schedule. Downstream pipelines are started by another pipeline, as child pipelines (same project) or multi-project pipelines (another project).

28. How do you validate .gitlab-ci.yml before pushing?

Use the pipeline editor in the GitLab UI, which validates as you type and shows the merged configuration with all includes expanded. The CI Lint tool does the same and can simulate a pipeline for a branch. For automation there is a CI lint API endpoint. YAML linters catch indentation errors, but only GitLab's own validation knows the keywords and limits.

29. How do you push a commit without starting a pipeline?

Put [skip ci] or [ci skip] in the commit message, or use the push option git push -o ci.skip. Both skip branch pipelines for that push. They are useful for documentation-only commits, but teams should not use them to dodge required checks.

30. How does a job push an image to the project's container registry?

GitLab provides CI_REGISTRY, CI_REGISTRY_IMAGE, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD in every job when the registry is enabled. The job logs in with them, builds, tags the image with something traceable such as CI_COMMIT_SHORT_SHA, and pushes. Our pipeline examples post shows a full build with Buildah, which avoids running a privileged Docker daemon.

31. What are environments and deployments?

An environment is a named target such as staging or production that GitLab tracks. A job with the environment keyword creates a deployment record each time it runs, so you can see which commit is live where, open the environment URL, and roll back by re-running an older deployment job.

deploy-staging:
  stage: deploy
  script: ./deploy.sh staging
  environment:
    name: staging
    url: https://staging.example.com

32. What does retry do, and what is its limit?

retry re-runs a failed job automatically. The value can be 0 (default), 1 or 2, so a job is tried at most three times. You can limit retries to specific causes with retry:when (for example runner_system_failure or api_failure) or to specific exit codes with retry:exit_codes. Retrying every script_failure tends to hide flaky tests rather than fix them.

GitLab CI/CD interview questions for 2 to 5 years of experience

33. What does needs do?

needs lets a job start as soon as the jobs it lists finish, instead of waiting for the whole previous stage. This builds a directed acyclic graph and often cuts pipeline time sharply. A job can list up to 50 jobs in needs on GitLab.com (self-managed defaults to 50 and an admin can change it). needs: [] starts the job immediately when the pipeline is created.

build-frontend:
  stage: build
  script: npm run build

build-backend:
  stage: build
  script: go build ./...

test-frontend:
  stage: test
  needs: ["build-frontend"]
  script: npm test

34. What is the difference between needs and dependencies?

needs controls both ordering and artifact download: the job starts when its needs finish and downloads their artifacts by default. dependencies only controls which earlier-stage jobs' artifacts are downloaded and does not change when the job starts. dependencies: [] downloads nothing. The docs advise not to combine the two in one job.

35. What do needs:artifacts and needs:optional do?

needs:artifacts: false keeps the ordering but skips downloading that job's artifacts, which saves time when you only need the sequence. needs:optional: true lets the job run even if the needed job was not added to the pipeline, for example because its rules did not match. Without optional, a missing needed job is a configuration error.

36. How do you avoid duplicate branch and merge request pipelines?

When a branch has an open merge request, a push can create both a branch pipeline and a merge request pipeline. Use workflow:rules to choose one. This pattern from the GitLab docs runs merge request pipelines when a merge request exists and branch pipelines otherwise:

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - if: $CI_COMMIT_BRANCH

37. How does rules:changes work, and what is compare_to for?

rules:changes adds the job when any listed file pattern changed (up to 50 patterns). Without compare_to it is always true for a new branch and for pipelines not triggered by a push, which surprises many people. rules:changes:compare_to sets the reference to diff against, such as the default branch, and must be used with rules:changes:paths.

docs-build:
  script: make docs
  rules:
    - changes:
        paths:
          - docs/**/*
        compare_to: "refs/heads/main"

38. What is rules:exists used for?

It adds a job only if certain files exist in the repository, such as a Dockerfile or a package.json. Shared templates use it so one include works across many projects: the Docker build job appears only in projects that have a Dockerfile.

39. How do you make a job manual in merge requests but automatic on main?

deploy-review:
  script: ./deploy-review.sh
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: manual
      allow_failure: true

allow_failure: true matters here. A manual job created through rules defaults to allow_failure: false, which would leave the merge request pipeline blocked until someone runs it.

40. What kinds of include are there?

TypeSourceNotes
include:localA file in the same repository and branchSupports * and ** wildcards
include:projectA file in another project on the same instancePin ref to a tag or full SHA
include:remoteA public HTTP or HTTPS URLNo authentication; add include:integrity with a SHA256 hash
include:templateGitLab's bundled templatesFor example Jobs/SAST.gitlab-ci.yml
include:componentA CI/CD componentFormat fqdn/path/name@version, can pass inputs

GitLab resolves includes before anything else, with a default limit of 150 includes per pipeline.

41. What is the difference between extends, !reference and YAML anchors?

extends makes a job inherit another job's configuration, usually a hidden template job, and merges hashes deeply. It works across included files. !reference copies one specific section, such as a script list or a rules list, from another job and also works across includes. YAML anchors are plain YAML and only work within a single file. In shared CI code, extends and !reference are easier to maintain.

.default-rules:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

.node-job:
  image: node:22
  before_script:
    - npm ci

lint:
  extends: .node-job
  script: npm run lint
  rules:
    - !reference [.default-rules, rules]

42. What is a hidden job?

A job whose name starts with a dot, such as .node-job, is not run. It exists to be reused through extends or !reference, or to temporarily disable a job without deleting it.

43. What do parallel and parallel:matrix do?

parallel: N runs N copies of a job (1 to 200), each with CI_NODE_INDEX and CI_NODE_TOTAL so test tools can split the suite. parallel:matrix runs one job per combination of variable values, for example every Python version on every OS. A matrix cannot produce more than 200 jobs.

test:
  image: python:$PYTHON_VERSION
  script: pytest
  parallel:
    matrix:
      - PYTHON_VERSION: ["3.11", "3.12", "3.13"]
        DB: ["postgres", "mysql"]

44. How does a job depend on one cell of a matrix?

Use needs:parallel:matrix with the exact identifiers and values from the matrix, in the same order. It cannot be combined with needs:optional.

deploy-py313:
  needs:
    - job: test
      parallel:
        matrix:
          - PYTHON_VERSION: "3.13"
            DB: "postgres"
  script: ./deploy.sh

45. What are parent-child pipelines?

A parent pipeline starts a child pipeline in the same project with a trigger job that points at another configuration file. Monorepos use this so each component has its own pipeline file that runs only when that component changes. The child can also be generated at runtime: one job writes a YAML file as an artifact, and the trigger job runs it with trigger:include:artifact.

frontend:
  trigger:
    include: frontend/.gitlab-ci.yml
    strategy: mirror
  rules:
    - changes:
        - frontend/**/*

46. What are multi-project pipelines, and how do mirror and depend differ?

A trigger job with trigger:project starts a pipeline in another project, for example to run end-to-end tests in a test project after a service builds. Without a strategy, the trigger job succeeds as soon as the downstream pipeline is created. strategy: mirror (GitLab 18.2 and later) makes the trigger job show exactly the downstream pipeline's status. The docs list depend as not recommended and point to mirror instead.

47. How are variables passed to downstream pipelines?

trigger:forward controls it. yaml_variables (default true) forwards variables defined in the trigger job and at the top level. pipeline_variables (default false) forwards variables that someone set when starting the upstream pipeline manually or by API. Forwarded variables are not passed further down a chain unless those trigger jobs also use trigger:forward.

48. How do you design a cache key for dependencies?

Key the cache on the lockfile with cache:key:files so the cache changes only when dependencies change. Add fallback_keys so a new branch can start from the default branch cache. Jobs that only read dependencies should use policy: pull so they do not spend time uploading an unchanged cache.

.npm-cache:
  cache:
    key:
      files:
        - package-lock.json
    paths:
      - .npm/
    fallback_keys:
      - npm-$CI_DEFAULT_BRANCH
    policy: pull

install:
  extends: .npm-cache
  cache:
    policy: pull-push
  script: npm ci --cache .npm --prefer-offline

49. Why might protected and unprotected branches not share a cache?

GitLab keeps caches for protected branches separate from unprotected ones by default, so code on a feature branch cannot poison the cache that a production build uses. cache:unprotect: true removes that separation, which you should only do when you accept the risk.

50. What are artifact reports?

artifacts:reports uploads files that GitLab parses and shows in the UI. junit shows test results in the merge request, coverage_report shows line coverage in the diff, and dotenv turns key=value lines into variables for later jobs. Security scanners also publish their findings this way. Reports are uploaded whatever the job result is.

test:
  script: pytest --junitxml=report.xml --cov --cov-report=xml
  artifacts:
    reports:
      junit: report.xml
      coverage_report:
        coverage_format: cobertura
        path: coverage.xml

51. How long are artifacts kept?

artifacts:expire_in sets the lifetime per job, such as 1 week or never. Without it, the instance-wide default applies. GitLab also keeps the artifacts from the most recent successful pipeline on each ref by default, even past expiry, so the latest build of main stays downloadable. Short expiry for large intermediate files saves storage.

52. How does the coverage keyword work?

coverage takes a regular expression wrapped in slashes. GitLab searches the job log, uses the last matching line and takes the first number in the match as the coverage percentage. It shows in the merge request and in the coverage history graph.

unit-tests:
  script: pytest --cov
  coverage: '/TOTAL.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'

53. How do you pass a value computed in one job to a later job?

Write it to a dotenv file and publish it as an artifacts:reports:dotenv report. Jobs that need or depend on that job get the values as variables. This is the usual way to pass a dynamic environment URL or a version number.

version:
  stage: build
  script:
    - echo "APP_VERSION=$(cat VERSION)-$CI_COMMIT_SHORT_SHA" >> build.env
  artifacts:
    reports:
      dotenv: build.env

deploy:
  stage: deploy
  needs: ["version"]
  script:
    - ./deploy.sh "$APP_VERSION"

54. What is resource_group for?

resource_group makes jobs that share the same group name run one at a time, even across different pipelines. Put every production deploy job in resource_group: production and two merges close together will deploy in sequence instead of overlapping. The default process mode is unordered; you can change it to oldest_first or newest_first through the API.

55. What do interruptible and workflow:auto_cancel do?

When a new commit arrives on a branch, GitLab can cancel the older, now redundant pipeline. Jobs marked interruptible: true can be cancelled. workflow:auto_cancel:on_new_commit sets the policy: conservative (default) cancels only if no non-interruptible job has started, interruptible cancels only interruptible jobs, and none cancels nothing. Mark test jobs interruptible and leave deploy jobs non-interruptible.

56. How do review apps and on_stop work?

A review app is a temporary environment per branch or merge request, named with a variable such as review/$CI_COMMIT_REF_SLUG. environment:on_stop names a job that tears it down, and environment:auto_stop_in stops it after a period such as 1 day. Redeploying resets the timer.

deploy-review:
  stage: deploy
  script: ./deploy-review.sh "$CI_COMMIT_REF_SLUG"
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    url: https://$CI_COMMIT_REF_SLUG.review.example.com
    on_stop: stop-review
    auto_stop_in: 1 day
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

stop-review:
  stage: deploy
  script: ./teardown-review.sh "$CI_COMMIT_REF_SLUG"
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    action: stop
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: manual
      allow_failure: true

57. What values can environment:action take?

start (default) creates a deployment. stop stops the environment. prepare, verify and access let a job use the environment, for example to run migrations, smoke tests or read logs, without creating a deployment record. Only start and stop affect deployments.

58. What is deployment_tier?

It tells GitLab what kind of environment this is: production, staging, testing, development or other. GitLab guesses the tier from the name, so set it explicitly when your production environment is called something like live-eu. Tier matters for DORA metrics and for production-specific features.

59. How do you stop just anyone deploying to production?

Protect the production environment so only chosen roles, groups or users can run deploy jobs for it (Premium and Ultimate). Add deployment approvals so a deploy waits for named approvers. Combine that with protected branches, protected CI/CD variables and a resource_group, and only reviewed code on main can reach production, one deploy at a time.

60. What are the masking rules for CI/CD variables?

A masked value must be a single line with no spaces, at least 8 characters long, and must not match an existing variable name. With variable expansion enabled, only a limited set of special characters is allowed. New variables are masked by default since GitLab 18.3. The masked and hidden option also prevents anyone from revealing the value in the UI after saving; it can only be chosen when creating the variable.

61. What is the order of precedence for CI/CD variables?

From highest to lowest, per the variables documentation: pipeline execution policy and scan execution policy variables, manual job variables, pipeline variables (set when triggering), project, group and instance variables, dotenv report variables, variables in .gitlab-ci.yml (rules:variables, then job, then workflow:rules:variables, then top-level), deployment variables and finally predefined variables. A project variable therefore overrides the same name in the YAML file.

62. How do you build container images in GitLab CI without privileged Docker?

Docker-in-Docker needs a privileged runner, which weakens isolation. GitLab documents Buildah as a daemonless option that can run unprivileged. The original kaniko repository was archived in June 2025, so it is no longer a safe default for new pipelines. Whatever the tool, tag images with the commit SHA and push to CI_REGISTRY_IMAGE.

63. What is CI_JOB_TOKEN, and how is it restricted?

CI_JOB_TOKEN is a token GitLab creates for each job. It is valid only while the job runs and has the permissions of the user who started the pipeline, limited to a set of APIs: the package and container registries, artifacts and cloning other projects. Other projects only accept the token if they add your project or group to their CI/CD job token allowlist, which by default contains only the project itself.

64. How do scheduled pipelines work?

A pipeline schedule runs a branch or tag on a cron expression in a chosen time zone, with optional variables. Jobs see CI_PIPELINE_SOURCE == "schedule", so you can run nightly security scans or long test suites only in scheduled pipelines and keep them out of merge requests.

65. What is a delayed job?

A job with when: delayed and start_in waits for the given time after its stage starts, between one second and one week. It is useful for a staged rollout such as deploying to a canary and then to everyone 30 minutes later, with the option to cancel during the wait. With rules, both when and start_in must be inside the rule.

66. How does the release keyword work?

release creates a GitLab release from a job, normally in a tag pipeline. It needs a script section and uses the glab CLI in the job image. tag_name is required; you can add a description, milestones and asset links. If the release already exists the job fails, so run it only once per tag.

release:
  stage: deploy
  image: registry.gitlab.com/gitlab-org/cli:latest
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - echo "Creating release $CI_COMMIT_TAG"
  release:
    tag_name: $CI_COMMIT_TAG
    description: "Release $CI_COMMIT_TAG"

67. How do you publish a GitLab Pages site from CI?

Add the pages keyword to a job (true or a hash). The site content comes from pages:publish, which defaults to public, and since GitLab 17.10 that path is added to the job's artifacts automatically. The older pattern of naming the job pages and using a top-level publish keyword is deprecated.

Senior GitLab CI/CD interview questions

68. What is a CI/CD component?

A component is a reusable, versioned piece of pipeline configuration with typed inputs. It lives in a component project with a README.md and a templates/ directory, where each component is either templates/name.yml or templates/name/template.yml. A project can hold up to 100 components. Components work on Free, Premium and Ultimate.

include:
  - component: $CI_SERVER_FQDN/my-org/ci-components/[email protected]
    inputs:
      node_version: "22"
      stage: test

69. How are components versioned and published to the CI/CD Catalog?

An Owner turns on the CI/CD Catalog project setting. The project needs a description, a README.md and at least one component. A release job using the release keyword runs on a tag that follows semantic versioning, such as 1.4.0. Consumers can pin a full version, a commit SHA, a partial version such as 1 or 1.4 (latest matching release) or ~latest. For production pipelines, pin a full version or SHA so an upstream change cannot alter your pipeline silently.

70. What is spec:inputs, and why prefer it over variables in templates?

spec:inputs declares parameters in a header section of the included file, separated from the jobs by ---. Inputs have a type (string, number, boolean or array), optional default, options, regex and description, and are referenced with $[[ inputs.name ]]. GitLab validates them when it builds the pipeline, so a wrong or missing value fails early with a clear error. Inputs can also change job names and stages, which variables cannot.

spec:
  inputs:
    stage:
      default: test
    node_version:
      type: string
      options: ["20", "22"]
      default: "22"
---
"node-test-$[[ inputs.node_version ]]":
  stage: $[[ inputs.stage ]]
  image: node:$[[ inputs.node_version ]]
  script:
    - npm ci
    - npm test

71. How would you structure CI for a monorepo with ten services?

Keep a thin root .gitlab-ci.yml with workflow:rules and one trigger job per service. Each trigger job uses rules:changes with compare_to the default branch and starts a child pipeline from that service's own file with strategy: mirror. Shared build and test logic lives in components or included templates with inputs. Use needs inside each child pipeline, and put a resource_group on each service's deploy job.

72. What is a merge train?

A merge train queues merge requests and tests each one together with all the merge requests ahead of it, so main is never broken by two changes that each passed alone. Up to 20 train pipelines run in parallel by default. If one fails, that merge request leaves the train and the ones behind it restart. Merge trains are a Premium and Ultimate feature and require merge request pipelines and merged results pipelines.

73. What is a merged results pipeline?

It runs the merge request pipeline against a temporary merge commit of the source branch into the current target branch, instead of against the source branch alone. It catches failures caused by changes that landed on main after the branch was created. It is the building block for merge trains.

74. How do you force security jobs into every project's pipeline?

Use pipeline execution policies (Ultimate, generally available since GitLab 17.3). A security team defines jobs in a policy project, and the policy adds them to the pipelines of the projects in scope. The inject_policy strategy adds the jobs without replacing the project's own configuration; override_project_ci replaces it. Jobs can run in the reserved .pipeline-policy-pre and .pipeline-policy-post stages. Compliance pipelines, the older approach, are deprecated, and the docs say to migrate from them.

75. How do you deploy to a cloud account without storing access keys?

Use id_tokens to request an OIDC token for the job with an audience the cloud provider expects. The cloud trusts GitLab as an identity provider and exchanges the token for short-lived credentials, limited by conditions on claims such as the project path and branch. Nothing long-lived sits in CI/CD variables.

deploy-aws:
  image:
    name: amazon/aws-cli:latest
    entrypoint: [""]
  id_tokens:
    AWS_OIDC_TOKEN:
      aud: https://gitlab.example.com
  script:
    - >
      export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s"
      $(aws sts assume-role-with-web-identity
      --role-arn "$ROLE_ARN"
      --role-session-name "gitlab-$CI_JOB_ID"
      --web-identity-token "$AWS_OIDC_TOKEN"
      --duration-seconds 3600
      --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]"
      --output text))
    - aws sts get-caller-identity
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

76. What does the secrets keyword do?

secrets (Premium and Ultimate) fetches secrets from an external provider at job start and exposes them as CI/CD variables, by default as file-type variables. The YAML reference lists HashiCorp Vault, Azure Key Vault, Google Cloud Secret Manager and GitLab Secrets Manager (introduced in GitLab 19.0). Authentication uses an ID token chosen with secrets:token.

77. How would you design a runner fleet for a large organisation?

Use autoscaling executors so capacity follows demand: the Kubernetes executor on a cluster, or the Docker Autoscaler or Instance executor, which use fleeting plugins for AWS, Google Cloud and Azure. Docker Machine autoscaling is deprecated, so plan migrations off it. Split runners by trust level (protected runners for deploys, general runners for merge requests), by architecture, and by special hardware, and route jobs with tags. Set concurrent and per-runner limits, put caches in shared object storage, and monitor queue time.

78. What are the main security risks with runners?

Privileged containers (needed for Docker-in-Docker) can break out of isolation. Shell executors share one host between jobs. A runner that runs jobs from any branch can leak deploy credentials to unreviewed code. Mitigations: avoid privileged mode, use ephemeral job environments, mark deploy runners as protected so they only run jobs from protected branches and tags, keep production credentials protected, and keep runners patched.

79. How do you protect a pipeline against supply chain changes in included code?

Pin include:project and components to a tag or full commit SHA, not a branch. Add include:integrity with a SHA256 hash to remote includes, so a changed file fails the pipeline. Pin container images by digest for sensitive jobs. Review changes to shared CI projects like any production code, with CODEOWNERS on the CI files.

80. Who can override variables when running a pipeline?

The project setting for the minimum role allowed to use pipeline variables (ci_pipeline_variables_minimum_override_role) controls it, with options no_one_allowed, owner, maintainer and developer. On GitLab.com new projects in new namespaces default to no_one_allowed; self-managed defaults to maintainer. Restricting it stops someone from overriding a variable to change what a deploy job does.

81. A pipeline takes 40 minutes. What do you look at first?

Find where the time goes: queue time (not enough runners or a tag mismatch) versus run time. Then, in rough order of payoff: add needs so independent jobs stop waiting for whole stages, split long test suites with parallel, fix cache keys so dependencies are not downloaded every time, use smaller images and avoid installing tools in every job, skip work with rules:changes, set needs:artifacts: false where artifacts are not used, and mark jobs interruptible so outdated pipelines are cancelled.

82. How do you deploy to Kubernetes from GitLab CI today?

Install the GitLab agent for Kubernetes in the cluster and authorise your project in the agent's configuration with ci_access. The agent connects out to GitLab, and CI jobs get a kubectl context named path/to/agent-project:agent-name, so no kubeconfig is stored in variables. environment:kubernetes:agent links the environment to the agent for the dashboard. The older certificate-based cluster integration should not be used for new setups.

83. How does GitOps fit with GitLab?

In a GitOps setup, CI builds and tests the image and then updates a manifest or Helm values file in a Git repository. A controller in the cluster pulls that change and applies it, so the cluster never needs to accept pushes from CI. GitLab's docs describe this pull model using Flux together with the agent for Kubernetes. Argo CD is another common controller. Our GitOps guide covers the model in more depth.

84. How do you add security scanning, and what does it need?

Include GitLab's templates, such as Jobs/SAST.gitlab-ci.yml and Jobs/Secret-Detection.gitlab-ci.yml, or the equivalent components. SAST and pipeline secret detection run on every tier. Showing the findings in the merge request security widget and the vulnerability report needs Ultimate, and so does dependency scanning. The jobs run in the test stage, so that stage must exist.

85. How do you measure whether CI/CD is improving delivery?

Track pipeline duration, success rate and queue time from CI/CD analytics. Track the four DORA metrics (deployment frequency, lead time for changes, change failure rate and time to restore service), which GitLab calculates from deployments to production-tier environments in Ultimate. Without Ultimate you can still export pipeline and deployment data through the API. Correct deployment_tier values make the numbers trustworthy.

86. What does inherit do?

inherit:default and inherit:variables let a job opt out of all or some global defaults and top-level variables. For example, a trigger job or a lightweight notification job may need inherit: default: false so it does not pull a heavy image and before_script from default.

87. What is hooks:pre_get_sources_script used for?

It runs commands on the runner before the repository and submodules are cloned. Typical uses are Git configuration, such as setting a credential helper or enabling a Git option, and preparing the workspace on a reused machine. A job-level hooks block replaces default:hooks instead of merging with it.

Scenario-based GitLab CI/CD interview questions

88. Jobs stay in pending and never start. How do you debug it?

Pending means no runner has picked the job up. Open the job page: GitLab says whether there are no runners with matching tags. Check that the job's tags exactly match an online runner (tags are case sensitive), that the runner is assigned to this project or group, that it accepts untagged jobs if the job has none, and that protected runners are not the only ones available for an unprotected branch. Then check the runner host: gitlab-runner status, the runner logs, and whether concurrent is already used up.

89. Every push to a merge request branch creates two pipelines. Why?

The jobs have rules that match both branch pipelines and merge request pipelines, often a final rule with no condition. Add workflow:rules (question 36) so the project runs either a merge request pipeline or a branch pipeline for each push, and remove catch-all rules from jobs.

90. A deploy job works on main but the same job on a feature branch says the API key is empty. Why?

The variable is protected, so GitLab only exposes it to pipelines on protected branches and tags. That is working as designed. For feature branches, use a separate unprotected variable scoped to a non-production environment, or keep the job off feature branches with rules. Do not unprotect a production secret to make the job pass.

91. The cache never seems to hit. What do you check?

Check that the key is stable: a key built from CI_COMMIT_SHA or CI_PIPELINE_ID changes every time. Check that the paths are inside the project directory, that the job that writes the cache has policy pull-push and succeeds (cache uploads on success by default), and that the jobs run on runners sharing the same cache storage. Remember that protected and unprotected branches use separate caches. The job log prints the key used and whether the cache was found.

92. A test job cannot find the build output from the build job. What went wrong?

Common causes: the build job did not declare artifacts:paths for that directory, the path is outside the project directory, the artifacts expired, the test job uses needs with artifacts: false or dependencies: [], or the build job failed and artifacts:when was on_success. Start by checking the build job's artifact browser, then the test job's needs or dependencies.

93. Two merges five minutes apart produced overlapping production deploys. How do you prevent it?

Add resource_group: production to the deploy job so deploys run one at a time across pipelines. Set the resource group's process mode to newest_first or oldest_first through the API if order matters. Leave deploy jobs non-interruptible so a newer pipeline does not cancel a deploy halfway through, and consider a merge train so main only moves forward through tested states.

94. A child pipeline failed but the parent pipeline is green. Why?

The trigger job has no strategy, so it succeeds as soon as the child pipeline is created. Set trigger:strategy: mirror so the trigger job reflects the child pipeline's status. Then a failed child marks the trigger job failed and the parent pipeline follows.

95. A pipeline that took 10 minutes now takes 35. How do you investigate?

Compare a recent pipeline with an older one job by job. If queue time grew, look at runner capacity and whether a new tag limited the job to fewer runners. If run time grew, look at the job logs for longer dependency downloads (cache key changed or cache storage lost), a bigger base image, new test suites, or a new included template that added jobs. Fix the specific cause, then add needs and parallel where the graph allows.

96. A token appeared in plain text in a job log. What do you do?

Treat it as leaked: revoke and rotate the token first. Erase the job log, since project members and possibly the public can read logs. Then find why masking failed. Often the variable was not masked, the value did not meet the masking rules, or the script printed it in a transformed form, such as base64, that masking cannot match. Remove the set -x or echo that printed it, and add secret detection to catch credentials committed to the repository.

97. A job with rules:changes runs on every new branch even when its files did not change. Why?

Without compare_to, rules:changes is always true for the first pipeline on a new branch because there is no previous commit on that branch to compare with. Add rules:changes:compare_to with the default branch, or use merge request pipelines, where changes compares against the target branch.

98. Your manager wants production deploys only from main, approved by a lead, never at the same time. How do you set that up?

  1. Protect main so only reviewed merges land there.
  2. Give the deploy job rules that add it only when CI_COMMIT_BRANCH equals CI_DEFAULT_BRANCH.
  3. Set environment: name: production with deployment_tier: production.
  4. Protect the production environment and add a deployment approval rule for the leads group (Premium or Ultimate).
  5. Store production credentials as protected variables, or better, use id_tokens with a cloud role that trusts only the main branch.
  6. Add resource_group: production.

99. After a refactor, GitLab reports the pipeline configuration is invalid and no pipeline is created. How do you fix it fast?

Open the pipeline editor or CI Lint on that branch. It shows the exact error and the merged configuration after includes and extends are resolved, which is where most refactor errors hide: a renamed hidden job still referenced by extends, a !reference to a path that no longer exists, a needs entry pointing at a job whose rules exclude it, or a missing stage. Fix it, validate again, and add a CI Lint check to merge requests that touch CI files.

100. An integration test fails about one run in ten. Should you add retry: 2?

Not as the fix. Retrying every failure hides the flake and wastes runner time. Limit automatic retries to infrastructure causes with retry:when, such as runner_system_failure, runner_interrupted or api_failure. Quarantine the flaky test, find the cause (shared state, timing, an unready service container) and fix it. The JUnit report helps you track which test fails.

101. How would you migrate a Jenkins pipeline to GitLab CI/CD?

Map concepts first: Jenkins stages become stages or needs, agents become runners with tags, credentials become CI/CD variables, id_tokens or the secrets keyword, shared libraries become CI/CD components or included templates, and post blocks become after_script or jobs with when: on_failure or always. Migrate one service at a time, run both systems in parallel until results match, and switch merge request checks to GitLab last. Our GitLab CI vs Jenkins comparison covers the differences in more detail.

Keywords to revise the night before

KeywordOne-line meaningCommon trap
rulesFirst matching rule decides if and how a job is addedNo match means the job is not added
workflow:rulesDecides whether the whole pipeline is createdOnly when: always or never is valid here
needsStart when listed jobs finish; download their artifactsLimit of 50 jobs by default
includePull in local, project, remote, template or component configPin project and component includes
cacheReuse dependencies across pipelinesNot guaranteed; separate for protected branches
artifactsKeep and pass job outputExpire; must be inside the project directory
environmentTrack deployments to a named targeton_stop job needs action: stop
resource_groupOne job at a time per groupApplies across pipelines, not only within one
triggerStart a child or multi-project pipelineUse strategy: mirror to see downstream status
retryRe-run a failed jobMaximum value is 2

How to prepare beyond these questions

Build a small project and break it on purpose: give a job a tag no runner has, protect a variable and use it on a feature branch, change a cache key, and remove an artifact path. Explaining a failure you have caused yourself is the most convincing answer in an interview. If you are preparing for a wider DevOps interview, the 200+ DevOps interview questions hub covers Linux, Git, Docker, Kubernetes and the other topics around GitLab.

For guided, hands-on practice with runners, components and deployment pipelines, our GitLab training runs in the classroom in Kharadi, Pune and live online across India. It also fits into the broader DevOps training program.

Frequently asked questions

Which GitLab CI/CD topics are asked most in interviews?

Rules and workflow:rules, the difference between cache and artifacts, needs, runners and executors, environments and protected deployments, and troubleshooting a pending or failed job. Experienced candidates also get questions on includes, components, parent-child pipelines and securing credentials.

Are only and except still accepted in GitLab CI?

They still work for backward compatibility, but GitLab lists them as deprecated and they could be removed in a future major version. Use rules in new pipelines and in interview answers, and mention that rules cannot be mixed with only/except in the same job.

Do I need a paid GitLab tier to practise these questions?

No. Pipelines, runners, rules, needs, includes, components, environments, artifacts and cache all work on the Free tier, including GitLab.com. Protected environments with approvals, merge trains and the secrets keyword need Premium; pipeline execution policies and dependency scanning need Ultimate.

What is the difference between cache and artifacts in one sentence?

Cache speeds up jobs by reusing dependencies across pipelines and may be missing, while artifacts carry a job's output to later jobs and to users and are kept until they expire.

How do I register a GitLab Runner in 2027?

Create the runner in the GitLab UI or API, copy the runner authentication token that starts with glrt-, and run gitlab-runner register with --token. The legacy registration token workflow has been disabled by default since GitLab 17.0.

What are GitLab CI/CD components?

Components are reusable, versioned pipeline building blocks with typed inputs, stored in a templates/ directory of a component project and included with include:component. Published versions appear in the CI/CD Catalog so other teams can find and pin them.

How should I answer scenario-based GitLab questions?

State the likely cause, say how you would confirm it (job log, CI Lint, runner status, variable settings), give the fix, and end with how you would prevent it next time. Interviewers look for an ordered process more than a single exact answer.

Is a GitLab certification needed to get a GitLab CI/CD job?

Employers rarely require one. Hands-on pipelines you can explain in detail carry more weight. If you want a certification as well, see our GitLab certification interview questions post.

Official references

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.