Posted in

Top 30 GitLab CI/CD Interview Questions and Answers for All Experience Levels

Prepare for your GitLab CI/CD interview with these 30 essential questions covering basic, intermediate, and advanced concepts. This guide progresses from foundational topics for freshers to complex scenarios suitable for 1-6 years of experience, helping you master pipelines, jobs, runners, and more in GitLab CI/CD.

Basic GitLab CI/CD Questions (1-10)

1. What is GitLab CI/CD?

GitLab CI/CD is an integrated continuous integration and continuous delivery system that automates building, testing, and deploying code directly within GitLab repositories using configuration files.

2. What is the .gitlab-ci.yml file?

The .gitlab-ci.yml file is a YAML configuration file placed at the root of a GitLab repository that defines the CI/CD pipeline structure, including jobs, stages, and scripts to execute.

3. What are the main keywords in GitLab CI/CD?

Main keywords include stages, jobs, script, before_script, after_script, variables, and artifacts for defining pipeline behavior.

4. Explain stages vs jobs in GitLab CI/CD.

Stages are named groups of jobs that run sequentially, such as build, test, and deploy. Jobs are individual executable units within stages that run in parallel if in the same stage.

5. What is a GitLab Runner?

A GitLab Runner is an agent that executes jobs defined in the .gitlab-ci.yml file by picking up pipelines from GitLab and running scripts on available executors.

6. What is the purpose of the script keyword?

The script keyword defines the list of shell commands that execute within a job to perform tasks like building or testing code.

7. How do you define a pipeline in GitLab CI/CD?

A pipeline is defined in the .gitlab-ci.yml file by specifying stages and jobs, where GitLab automatically triggers the pipeline on code pushes or merge requests.

8. What are the key components of GitLab CI/CD?

Key components include the .gitlab-ci.yml file, pipelines, runners, jobs, stages, artifacts, and environments for managing the full CI/CD workflow.

9. What is the role of environment variables in GitLab CI/CD?

Environment variables store credentials, secrets, or configuration settings that jobs can access dynamically during execution.

10. How do you run a job manually in GitLab CI/CD?

Use the when: manual attribute in the job definition to require manual intervention before the job triggers.

Intermediate GitLab CI/CD Questions (11-20)

11. What is the needs keyword in GitLab CI/CD?

The needs keyword allows jobs to run concurrently across different stages by specifying direct dependencies, bypassing stage sequencing.

job2:
  stage: test
  needs: ["job1"]

12. How can you pass artifacts between stages?

Define artifacts in the producing job and use the dependencies keyword in dependent jobs to retrieve them automatically.

13. How do you handle secret management in GitLab CI/CD?

Use GitLab’s CI/CD variables marked as protected or masked, along with integrations for secure storage and retrieval in pipelines.

14. What are GitLab CI/CD templates?

Templates are reusable YAML configurations provided by GitLab or custom ones for common tasks like building or deploying, included via the include keyword.

15. How do you debug failed jobs in GitLab CI/CD?

Enable debug logging with variables, review job logs in the UI, retry jobs, or use SSH for interactive debugging on the runner.

16. What is a dynamic environment in GitLab CI/CD?

Dynamic environments are auto-created temporary environments for branches or merge requests, useful for review apps and testing specific changes.

17. How do you manage conditional job execution?

Use rules, only, except, or if conditions based on branches, variables, or pipeline types to control job execution.

job:
  rules:
    - if: $CI_COMMIT_BRANCH == "main"

18. What are Value Streams in GitLab?

Value Streams provide end-to-end DORA metrics like deployment frequency, lead time, MTTR, and change failure rate to measure pipeline efficiency.

19. How do you cache files in GitLab CI/CD to speed up builds?

Use the cache keyword to store and reuse directories like node_modules or Docker layers between job runs.

20. Explain how to enforce merge request approval rules based on pipeline status at Atlassian.

Configure merge request settings to require a successful pipeline status plus code owner approvals before merging changes.

Advanced GitLab CI/CD Questions (21-30)

21. How do you run jobs only when specific files change?

Use rules:changes with file paths to trigger jobs only if relevant files are modified in the commit.

rules:
  - changes:
      - src/**/*
      - tests/**

22. How do you generate and publish code coverage badges?

Parse coverage output in a job and use regex in the coverage keyword to auto-generate badges displayed in the merge request widget.

coverage: '/Covered: \d+%/'

23. What is GitLab CI/CD for Terraform at Salesforce?

Use GitLab’s Terraform templates with remote state stored in GitLab’s backend, applying plan and apply jobs in protected environments.

24. How do you implement database migrations safely in production?

Create a separate manual migration job with confirmation gates, running in a protected environment after tests pass.

25. How do you use GitLab Feature Flags with CI/CD at Adobe?

Integrate Feature Flags API in CI jobs to toggle features dynamically during staging or production deployments.

26. How do you implement compliance pipelines?

Enforce compliance frameworks using required pipeline templates at the group level for security scans and approvals.

27. What are reusable pipeline components in GitLab?

Reusable components are YAML templates stored in a catalog, included across projects for standardized workflows like testing or deployment.

28. How do you optimize runner costs?

Enable interruptible jobs, autoscaling runners, and spot instances to reduce expenses while maintaining availability.

29. How do you implement database rollback in GitLab CI/CD at Swiggy?

Use a manual rollback job with down migrations or blue-green database switching triggered post-deployment failure.

30. What is the GitLab Runner Fleet Dashboard?

The Runner Fleet Dashboard provides a centralized view of all runners’ health, usage, and performance across projects and groups.

Leave a Reply

Your email address will not be published. Required fields are marked *