GitLab CI/CD Preparation Guide for Freshers (2027)

A four-week GitLab CI/CD interview plan with 32 answers for freshers and experienced: pipelines, rules, runners, cache, variables, OIDC and merge trains.

Sep 17, 2025 - 15:27
Nov 12, 2026 - 17:09
 0  54
GitLab CI/CD Preparation Guide for Freshers (2027)

To prepare for GitLab CI/CD interviews, learn the pipeline model first (stages, jobs, rules, needs), then runners, caching and artifacts, variables and secrets, reusable configuration and security scanning. Freshers should be able to write and explain a working .gitlab-ci.yml. Experienced candidates should explain runner scaling, OIDC, merge trains and failure handling. This guide gives a four-week plan and 32 answers.

Every keyword, default and limit below was checked against the GitLab documentation in November 2026. If you want a pure question bank instead of a study plan, use our 90+ GitLab CI/CD interview questions.

Key takeaways

  • Interviewers start with the shape of a pipeline: stages run in order, jobs in a stage run in parallel, and a job without a stage lands in test.
  • Use rules, not only and except. GitLab marks the older pair as deprecated.
  • Cache holds downloaded dependencies. Artifacts pass build output between jobs and expire after 30 days by default.
  • For cloud access, expect to be asked about id_tokens (OIDC) instead of stored cloud keys.
  • Merge trains need the Premium or Ultimate tier. Say so when you mention them.
  • Practise by building one real pipeline end to end. Reading alone does not hold up in a live round.

A four-week GitLab CI/CD study plan

WeekLearnBuild to prove it
1Stages, jobs, script, image, variables, artifacts, cacheA pipeline that builds, tests and packages a small app
2rules, needs, workflow, merge request pipelines, environmentsSeparate branch, merge request and tag behaviour in one file
3Runners, executors, tags, protected variables, OIDC with id_tokensRegister a runner and deploy to a test environment without stored keys
4include, components, extends, SAST, failure handlingSplit the pipeline into a reusable template and add a scan job

If you do not have a GitLab project yet, create a free one on GitLab.com. A basic project is enough for weeks 1 and 2. For ideas on what to build, read 15 GitLab CI/CD pipeline examples.

Level 1: pipeline basics for freshers

1. What is GitLab CI/CD?

It is the build and delivery system built into GitLab. You describe jobs in a .gitlab-ci.yml file in the repository, and GitLab runs them on runners whenever the pipeline rules match, for example on a push or a merge request.

2. What are stages and jobs?

A job is a unit of work with a script. A stage groups jobs. Stages run in order, and jobs inside one stage run in parallel when runners are free. If you do not define stages, the defaults are .pre, build, test, deploy and .post.

3. Which stage does a job use if you forget stage?

It goes to test. This is a common trick question.

4. Write a minimal pipeline.

stages: [build, test]

build-app:
  stage: build
  image: node:22
  script:
    - npm ci
    - npm run build
  artifacts:
    paths:
      - dist/

unit-tests:
  stage: test
  image: node:22
  script:
    - npm test

Explain each line aloud. The image is the container the job runs in (on Docker or Kubernetes runners), and artifacts keeps dist/ for later jobs.

5. What is a runner?

A runner is the agent that picks up a job and runs it. GitLab describes three scopes: instance runners for the whole instance, group runners shared by projects in a group, and project runners for a single project that needs dedicated settings, credentials or hardware.

6. What is the difference between cache and artifacts?

Cache stores dependencies such as downloaded packages so later pipelines run faster. Artifacts are job output stored in GitLab and passed to later jobs or downloaded. Artifacts expire after 30 days by default, and a cache is not guaranteed to exist, so a job must still work without it.

7. How do you make a cache key follow your lock file?

cache:
  - key:
      files:
        - package-lock.json
    paths:
      - .npm/

The key is derived from the file contents, so the cache changes only when dependencies change.

8. What are CI/CD variables and what types exist?

Variables are key-value pairs exposed to jobs as environment variables. In the UI you can mark them masked (hidden in job logs), masked and hidden (value cannot be viewed after saving), protected (only for protected branches and tags) and file type (the value is written to a temporary file and the variable holds its path).

9. What does it take to mask a variable?

The value must be a single line with no spaces, at least 8 characters, and must not match the name of another variable. Masking only hides the value in logs. GitLab itself recommends a secrets manager for sensitive data.

10. How do you stop a job from running on every branch?

Use rules. For example, rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH runs the job only on the default branch.

11. Are only and except still used?

They still work for backward compatibility, but GitLab lists them as deprecated and recommends rules:if and rules:changes. New files should not use them.

12. What does allow_failure do?

It lets a job fail without failing the pipeline. It is false by default, except for manual jobs, where it defaults to true. You can narrow it with allow_failure:exit_codes.

Level 2: working knowledge (1 to 4 years)

13. How does needs change execution order?

A job with needs starts as soon as the listed jobs finish, without waiting for the whole previous stage. A job can list up to 50 needs, and needs: [] starts a job as soon as the pipeline is created.

14. How do you run the same job for several targets?

Use parallel:matrix. Each entry produces a job with its own variable values. The total cannot exceed 200 permutations.

deploy-stacks:
  parallel:
    matrix:
      - PROVIDER: aws
        STACK: [monitoring, app1]

15. What is workflow:rules for?

It decides whether the whole pipeline is created. If no workflow rule matches, no pipeline runs. It is the right place to stop duplicate branch and merge request pipelines.

16. What is a merge request pipeline?

A pipeline that runs on the source branch contents when a merge request is created or updated. The configuration must contain rules that match CI_PIPELINE_SOURCE == "merge_request_event", and those rules must be written in the main file, because rules brought in through include do not count.

17. What are merged results pipelines and merge trains?

A merged results pipeline tests the merge request combined with the target branch. A merge train is a queue: each merge request is tested against the ones ahead of it, which catches conflicts between changes that each pass alone. Merge trains need the Premium or Ultimate tier and the Maintainer role to enable.

18. How do you deploy to an environment safely?

Declare the environment with a name and URL, and use resource_group so two pipelines cannot deploy to it at once.

deploy-production:
  stage: deploy
  environment:
    name: production
    url: https://prod.example.com
  resource_group: production
  script:
    - ./deploy.sh
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: manual

19. How do you reuse configuration inside one file?

Create a hidden job whose name starts with a dot, then inherit it with extends. Keys are merged into the job, and GitLab supports up to eleven levels of inheritance.

20. How do you reuse configuration across projects?

Use include (local, project, remote or template) or CI/CD components. A component is included at a specific version, for example include: - component: $CI_SERVER_FQDN/my-org/security-components/[email protected]. Published components appear in the CI/CD Catalog and can use spec:inputs with $[[ inputs.name ]] for parameters.

21. How do you retry flaky jobs without hiding real failures?

Use retry with a type of failure. The maximum is 2 retries, and the default is 0. Retrying only on runner_system_failure or specific exit_codes leaves genuine test failures visible.

22. How do you add SAST to a pipeline?

Include the template Jobs/SAST.gitlab-ci.yml. It needs a Linux runner with the Docker or Kubernetes executor and a test stage. All tiers get the basic analyzers and a JSON report. Advanced SAST and some reporting views are Ultimate features.

23. What is the right way to pass a value between jobs?

Write it to an artifact file. A dotenv report can turn a file into variables for jobs that list the producer in needs or dependencies.

Level 3: design and operations (5+ years)

24. Which executor would you pick?

For clean container builds on a host with Docker, the Docker executor. For jobs that scale on demand in the cloud, Docker Autoscaler or Instance, both built on fleeting. For a cluster you already run, Kubernetes, which starts a new pod per job. Shell, SSH, VirtualBox, Parallels and Custom are in maintenance mode, and Docker Machine is deprecated.

25. When do you use GitLab-hosted runners versus self-managed ones?

GitLab-hosted runners suit teams that want no maintenance and a fresh VM per job. Self-managed runners suit private network access, custom hardware or security controls, and reuse of a warm environment.

26. How does a job get picked by the right runner?

GitLab matches runner tags, runner type, status, capacity and required capabilities. A job lists tags, and only runners with those tags can take it.

27. How do you avoid long-lived cloud keys in CI?

Use ID tokens. Declare id_tokens with an aud value and exchange the signed JWT for short-lived cloud credentials.

deploy:
  id_tokens:
    CLOUD_TOKEN:
      aud: https://cloud.example.com
  script:
    - ./login-with-token.sh "$CLOUD_TOKEN"

The token is signed with RS256 and expires with the job timeout, or after 5 minutes if no timeout is set. In the cloud trust policy, GitLab advises using stable claims such as namespace_id and project_id and never user_login or user_email alone. Older CI_JOB_JWT_V2 tokens are deprecated. More on secrets in 10 GitLab CI secrets for advanced automation.

28. Which variable wins when the same name is defined twice?

From highest to lowest: pipeline execution policy variables, manual job variables, pipeline variables, project variables, group variables, instance variables, dotenv report variables, variables in the YAML file, deployment variables, then predefined variables.

29. How do you protect production secrets from merge request pipelines?

Mark them protected. Merge request pipelines can read protected variables only when both branches are protected, in the same project, and the triggering user can push or merge to the target. Pipelines from forks never get them.

30. How would you speed up a slow pipeline?

Measure first, then apply the cheapest fixes: add needs so jobs stop waiting on stages, key the cache to lock files, split tests with parallel, and use smaller images. See 15 GitLab Runner optimization tips for runner-side tuning.

31. A deploy job ran twice at the same time and corrupted a release. What do you change?

Add resource_group to the deploy job so only one job in that group runs at a time across pipelines, and make the deploy script idempotent.

32. A merge request pipeline never starts. Where do you look?

Check that a rule matches merge_request_event in the main .gitlab-ci.yml and not only in an included file. Check that workflow:rules allow it, that the project is a GitLab repository rather than an external one, and that your role is Developer or higher.

How to practise answers

Say each answer in two sentences, then show the YAML. For scenario rounds, follow the order symptom, evidence, fix, prevention. Our scenario-based GitLab CI/CD questions and advanced GitLab questions give you more cases. If you are comparing tools before an interview, read GitLab CI and Jenkins compared. To practise with an instructor, see our GitLab training in Pune, offered in the classroom in Kharadi or live online.

FAQ

How long does it take to prepare for a GitLab CI/CD interview?

Four weeks of regular practice is enough for most candidates who already know Git and Linux basics. Spend the first two weeks on pipeline syntax and the last two on runners, security and scenarios.

Do I need GitLab Premium or Ultimate to practise?

No. Almost everything here works on the free tier. Merge trains need Premium or Ultimate, and Advanced SAST is an Ultimate feature, so study those from the documentation.

Should I still learn only and except?

Know that they exist because you will meet them in old repositories. Write new pipelines with rules, since GitLab lists the older keywords as deprecated.

What is the most asked GitLab CI/CD topic?

Pipeline structure and rules, followed by cache versus artifacts, variables and runners. Almost every round starts with one of them.

Is a GitLab certification required?

No. Most interviews test hands-on ability. A small project you can explain in detail helps more than a certificate.

What is the difference between a runner and an executor?

The runner is the agent that takes jobs. The executor is how that runner runs them, for example in Docker containers, in Kubernetes pods or directly in a shell.

How do I answer questions about secrets?

Say what you would avoid first (plain variables and long-lived keys), then name the safer option: protected and masked variables for low risk values, an external secrets manager, and OIDC ID tokens for cloud access.

Can I use GitLab CI/CD with Kubernetes?

Yes. You can run jobs in a cluster with the Kubernetes executor, and you can deploy to a cluster from a job. Both are common interview topics.

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.