GitLab CI/CD Interview Questions for Freshers (2027)
60 GitLab CI/CD interview questions for freshers with answers: .gitlab-ci.yml, stages, runners, executors, variables, artifacts vs cache and rules.
GitLab CI/CD interview questions for freshers test whether you can read and write a basic .gitlab-ci.yml: stages, jobs, scripts, runners, variables, artifacts, cache and rules. Interviewers want correct definitions, a small working pipeline you can explain line by line, and a calm way to read a failed job log. This page has 60 questions with answers.
Most of the questions here are for people preparing for their first DevOps or CI/CD role, with a shorter set for 2 to 5 years and senior candidates and a scenario section at the end. If you want the full question bank, go to our 90+ GitLab CI/CD interview questions and answers. For troubleshooting stories, read the real-time GitLab CI/CD questions and scenario-based GitLab CI/CD questions.
Key takeaways
- Know the building blocks by heart: pipeline, stage, job, runner, executor, artifact, cache, variable.
- GitLab's default stages are
build,testanddeploy, plus.preand.post, which always run first and last. - Use
rulesto control when jobs run. GitLab's documentation saysonlyandexceptare not being actively developed. - Artifacts pass build output to later jobs; cache speeds up dependency downloads. Mixing them up is the most common fresher mistake.
- Runners are now registered with runner authentication tokens created in the GitLab UI. The older registration token method is deprecated.
- Be ready to write a three-stage pipeline from memory and explain every line.
Where to start
| Your level | Questions | Practice task |
|---|---|---|
| Fresher or student | 1 to 35 | Create a project on GitLab.com and run a build, test, deploy pipeline |
| 2 to 5 years | 36 to 47 | Add merge request pipelines, needs, environments and a child pipeline |
| Senior | 48 to 53 | Design shared templates or CI/CD components for several teams |
| Everyone | 54 to 60 | Break a job on purpose and fix it from the log |
Freshers: GitLab CI/CD basics (questions 1 to 35)
1. What is GitLab CI/CD?
GitLab CI/CD is the automation built into GitLab that runs jobs when code changes. You describe the jobs in a .gitlab-ci.yml file at the root of the repository, and GitLab runners execute them to build, test and deploy the code.
2. What is the difference between continuous integration, delivery and deployment?
Continuous integration merges and tests code often. Continuous delivery keeps every change ready to release, with a manual approval before production. Continuous deployment releases every change that passes the pipeline to production automatically.
3. What is the .gitlab-ci.yml file?
It is the YAML file that defines your pipeline: stages, jobs, scripts, images, variables and rules. GitLab reads it on every push, merge request or schedule and creates a pipeline from it. The CI/CD path can be changed in project settings, but the default is the repository root.
4. What is a pipeline?
A pipeline is one run of your CI/CD configuration for a commit. It contains stages, and each stage contains jobs. You can see its status, graph and job logs under Build, Pipelines in the project.
5. What is a job?
A job is the smallest unit of work: a named block with a script that runs on a runner. Jobs in the same stage run in parallel when enough runners are available.
6. What is a stage?
A stage groups jobs. By default, all jobs in one stage must succeed before the next stage starts. You list the order with the stages keyword.
7. What are the default stages?
If you do not define stages, GitLab uses build, test and deploy. The special .pre and .post stages always run first and last. A job with no stage goes to test.
8. Write a simple three-stage pipeline.
This pipeline builds, tests and deploys a Node.js app, with the deploy job running only on the default branch.
stages:
- build
- test
- deploy
default:
image: node:20
build-job:
stage: build
script:
- npm ci
- npm run build
artifacts:
paths:
- dist/
test-job:
stage: test
script:
- npm ci
- npm test
deploy-job:
stage: deploy
script:
- ./deploy.sh
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
9. What is a GitLab runner?
A runner is an agent that picks up jobs from GitLab and runs them. GitLab.com provides hosted runners, and you can install GitLab Runner on your own machines or in Kubernetes.
10. What are the types of runners by scope?
Instance runners serve all projects on a GitLab instance, group runners serve every project in a group, and project runners serve specific projects. Self-managed GitLab admins choose which are available.
11. What is an executor?
The executor decides how a runner runs a job. Common ones are Shell (directly on the host), Docker (in a container), Kubernetes (in a pod), and autoscaling options such as Docker Autoscaler and Instance. Docker is the most common choice for freshers to learn.
12. How do you register a runner today?
Create the runner in the GitLab UI (project, group or admin settings), copy the runner authentication token it shows, then run gitlab-runner register on the machine with that token. The older registration token workflow is deprecated.
13. What are tags on a job?
tags pick which runners can take the job. A job tagged docker only runs on runners that have the docker tag. If no matching runner is online, the job stays pending.
14. What does the image keyword do?
It sets the container image a job runs in when the runner uses the Docker or Kubernetes executor. Put it under default to apply it to every job, or in one job to override it.
15. What is before_script and after_script?
before_script runs before the main script, often to install tools. after_script runs afterwards even if the job failed, in a separate shell, and is good for cleanup.
16. What are CI/CD variables?
Variables are key-value pairs available to jobs as environment variables. You define them in the YAML file, in project or group settings, or when running a pipeline manually. GitLab also provides predefined variables.
17. Name some predefined variables.
CI_COMMIT_BRANCH, CI_COMMIT_SHA, CI_COMMIT_SHORT_SHA, CI_DEFAULT_BRANCH, CI_PIPELINE_SOURCE, CI_PROJECT_DIR, CI_REGISTRY_IMAGE and CI_JOB_TOKEN are used often.
18. What are protected and masked variables?
A protected variable is only passed to pipelines on protected branches or tags. A masked variable is hidden in job logs. GitLab also has a masked and hidden option, which hides the value in the settings screen after you save it. Use both protection and masking for secrets.
19. What is an artifact?
An artifact is a file or folder a job saves after it finishes, such as a build output or test report. Later jobs download artifacts from earlier stages automatically, and you can download them from the UI.
20. What is cache?
Cache stores files such as downloaded dependencies between pipeline runs to save time. It is a best-effort speed-up, not a guaranteed handoff, so a job must still work when the cache is empty.
21. Artifacts or cache: when do you use which?
Use artifacts to pass results of a job to later jobs in the same pipeline. Use cache for things you can download again, like node_modules or a Maven repository.
test-job:
cache:
key:
files:
- package-lock.json
paths:
- .npm/
script:
- npm ci --cache .npm --prefer-offline
- npm test
22. What does expire_in do?
artifacts:expire_in sets how long artifacts are kept, for example 1 week. Expiring old artifacts saves storage. By default, artifacts from the latest successful pipeline on a branch can be kept even after they expire, depending on project settings.
23. What is the rules keyword?
rules decides whether a job is added to the pipeline, using conditions such as if, changes and exists. GitLab checks rules in order and uses the first match.
deploy-job:
script: ./deploy.sh
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: manual
- when: never
24. Why prefer rules over only and except?
rules is more flexible and supports variables, file changes and when values in one place. GitLab's documentation says only and except are not being actively developed, and you cannot mix them with rules in the same job.
25. What does when: manual do?
It makes a job wait for someone to click a play button. Teams use it for production deploys or other steps that need a human decision.
26. What does allow_failure mean?
If a job with allow_failure: true fails, the pipeline continues and shows a warning instead of failing. Use it for checks that are useful but not yet required.
27. What is a merge request pipeline?
A pipeline that runs for a merge request rather than a plain branch push. You create one by adding a rule such as if: $CI_PIPELINE_SOURCE == "merge_request_event". Its results show in the merge request.
28. What is the GitLab container registry?
Each project can have a built-in container registry. Jobs can log in with the predefined variables CI_REGISTRY, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD and push images to $CI_REGISTRY_IMAGE.
29. How do you build a Docker image in a pipeline?
One common way is Docker-in-Docker with the docker:dind service on a runner configured for it. Many teams prefer daemonless tools such as Buildah or Kaniko-style builders to avoid privileged mode.
build-image:
image: docker:27
services:
- docker:27-dind
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
30. What is an environment in GitLab?
An environment, such as staging or production, records where code is deployed. Adding environment: production to a deploy job shows deployment history and lets you roll back from the UI.
31. How do you check your YAML before pushing?
Use the pipeline editor in the GitLab UI. It validates syntax, shows a visual graph and can show the merged configuration after includes.
32. What is a scheduled pipeline?
A pipeline that runs on a cron-style schedule, set under Build, Pipeline schedules. It is useful for nightly tests or dependency scans. In rules, $CI_PIPELINE_SOURCE == "schedule" identifies these runs.
33. What does the include keyword do?
include pulls YAML from other files: a local file, another project, a remote URL, a GitLab template or a CI/CD component. It keeps long pipelines readable and lets teams share configuration.
34. What does extends do?
extends lets a job reuse configuration from another job, often a hidden job whose name starts with a dot.
.node-job:
image: node:20
before_script:
- npm ci
lint:
extends: .node-job
script: npm run lint
35. What is GIT_DEPTH?
It sets how many commits the runner fetches. A shallow clone is faster. Increase it, or set it to 0 for a full clone, if a job needs history, for example to compare against another branch.
2 to 5 years: everyday pipeline design (questions 36 to 47)
36. What does needs do?
needs lets a job start as soon as the jobs it depends on finish, without waiting for the whole previous stage. This builds a directed acyclic graph and shortens pipelines.
37. What is a parent-child pipeline?
A parent job uses trigger with include to start a child pipeline from another YAML file in the same project. It is useful for monorepos where each component has its own pipeline.
38. What is a multi-project pipeline?
A job that uses trigger: project: group/other-project to start a pipeline in another project, for example running integration tests after a library change.
39. What is parallel: matrix?
It creates several copies of a job with different variable values, such as testing on several language versions.
test:
script: python -m pytest
parallel:
matrix:
- PYTHON_VERSION: ["3.11", "3.12", "3.13"]
image: python:$PYTHON_VERSION
40. What does workflow: rules do?
It decides whether a whole pipeline is created. A common use is avoiding duplicate pipelines by running either a merge request pipeline or a branch pipeline, not both.
41. What is interruptible?
A job marked interruptible: true can be cancelled when a newer pipeline starts on the same branch, if auto-cancel is enabled. It saves runner time on superseded commits.
42. What is resource_group?
It makes sure only one job in that group runs at a time across pipelines. Deploy jobs use it so two deployments to the same environment do not overlap.
43. What are CI/CD components and the CI/CD Catalog?
Components are reusable, versioned pipeline building blocks published from a project. The CI/CD Catalog lists them so other projects can include them with a version, for example include: - component: $CI_SERVER_FQDN/my-group/my-component/[email protected].
44. How do you authenticate deployments to a cloud without long-lived secrets?
Use ID tokens (id_tokens) for OpenID Connect. The cloud provider trusts GitLab's tokens and exchanges them for short-lived credentials, so you do not store access keys as variables.
45. How do you deploy to Kubernetes from GitLab?
Options include running kubectl or Helm in a job with a kubeconfig from a protected variable, using the GitLab agent for Kubernetes, or pushing manifests to a repository watched by a GitOps tool such as Argo CD or Flux.
46. How do you show test results in a merge request?
Publish JUnit XML with artifacts:reports:junit. GitLab parses it and shows failed tests in the merge request and pipeline views.
47. How do you speed up a slow pipeline?
Measure job durations first. Then use needs, cache dependencies with a lock-file key, split long test suites with parallel, use smaller images, and skip jobs with rules:changes when their files did not change. Our GitLab runner optimization tips go further.
Senior: standards and governance (questions 48 to 53)
48. How would you share pipeline standards across many teams?
Publish versioned CI/CD components or include templates from a central project, document inputs, and let teams pin versions. Use compliance pipelines or security policies where certain jobs must always run.
49. How do you secure runners?
Separate runners for trusted and untrusted work, avoid privileged mode where possible, use ephemeral autoscaled machines or pods, restrict protected runners to protected branches, and keep runner hosts patched.
50. How do you protect production deploys?
Use protected branches and environments, required approvals for deployments, protected variables, resource_group to serialize deploys and when: manual or approval rules for the final step.
51. How do you add security scanning?
Include GitLab's scanning templates or components for SAST, secret detection, dependency scanning and container scanning. Some scanners and the security dashboard depend on the GitLab tier, so check the documentation for your subscription.
52. How would you structure CI for a monorepo?
Use rules:changes so only affected parts build, and a parent pipeline that triggers child pipelines per component. Keep shared logic in components to avoid copy-paste.
53. How do you keep pipeline costs under control?
Auto-cancel redundant pipelines, mark jobs interruptible, expire artifacts, right-size runner machines, and track minutes or runner usage per project.
Scenario questions (questions 54 to 60)
54. A job has been "pending" for a long time. What do you check?
Check whether any online runner matches the job's tags, whether project or group runners are enabled, and whether hosted runner minutes are available. The job page usually says "no runners that match all of the job's tags".
55. A job fails with "command not found". How do you fix it?
The tool is not in the job's image. Use an image that includes it, install it in before_script, or build a custom image. Print the image name and which output to confirm.
56. The test job cannot find the build output. Why?
The build job did not save it as an artifact, the path was wrong, or the test job uses needs or dependencies that exclude the build job. Check the artifact list on the build job page.
57. A secret variable is empty in a branch pipeline. Why?
It is probably a protected variable and the branch is not protected. Either protect the branch or run the job only on protected branches.
58. Two pipelines run for every merge request push. How do you stop it?
Both a branch pipeline and a merge request pipeline are created. Add workflow: rules that run merge request pipelines when a merge request is open and branch pipelines otherwise.
59. The deploy job runs on feature branches. How do you restrict it?
Add a rule such as if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH and protect the target environment so only allowed users can deploy.
60. Cache never seems to work. What do you check?
Confirm the cache key matches between runs, the paths are inside the project directory, and the runners share cache storage (distributed cache for autoscaled runners). Different runners without shared cache start empty.
How to practise before the interview
- Create a free project on GitLab.com, push a small app and add the pipeline from question 8.
- Add a cache, a test report, a manual production deploy and an environment.
- Break three things on purpose: a wrong image, a missing artifact, a wrong rule. Fix each from the log.
- Read real examples in our 15 GitLab CI/CD pipeline examples with YAML.
Our GitLab training covers these topics with labs, in a classroom in Kharadi, Pune and live online. For broader preparation, use the 200 DevOps interview questions guide.
Frequently asked questions
What GitLab CI/CD topics are asked to freshers?
Pipelines, stages, jobs, runners and executors, the .gitlab-ci.yml structure, variables, artifacts versus cache, rules and simple Docker builds. Expect to write or explain a small three-stage pipeline.
What is the difference between artifacts and cache in GitLab?
Artifacts pass job output to later jobs and can be downloaded. Cache speeds up repeated downloads such as dependencies between runs, and jobs must still work without it.
Should I use rules or only/except?
Use rules. GitLab's documentation says only and except are not being actively developed, and rules covers the same cases with more control.
What is a GitLab runner executor?
The executor decides how a runner runs a job: directly on the host (Shell), in a container (Docker), in a Kubernetes pod, or on autoscaled machines.
How do I register a GitLab runner now?
Create the runner in the GitLab UI, copy the runner authentication token, and use it with gitlab-runner register. The old registration token method is deprecated.
Do I need a GitLab certification to get a job?
No. A working pipeline in a public project that you can explain clearly usually matters more in fresher interviews. GitLab's certification pages list current exams if you want one.
How many GitLab CI/CD questions are in this guide?
Sixty: 35 for freshers, 12 for 2 to 5 years, 6 for senior candidates and 7 scenarios.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0