DevOps / GitLab CI Basics Interview Questions
What is the.gitlab-ci.yml file and where must it be placed?
The .gitlab-ci.yml file is the pipeline configuration file for GitLab CI/CD. It uses YAML syntax to define stages, jobs, scripts, rules, and all other pipeline behaviour. GitLab automatically detects and runs the pipeline whenever this file is present and a triggering event occurs.
Key facts:
- Must be placed at the root of the repository by default
- The filename is case-sensitive - it must be exactly
.gitlab-ci.yml - You can configure a different path/filename in Settings > CI/CD > General pipelines > CI/CD configuration file
- It is a regular file tracked by Git, so all changes are version-controlled and can be reviewed in merge requests
# Minimal .gitlab-ci.yml stages: - build - test - deploy build-job: stage: build script: - echo "Compiling the code..." - echo "Compile complete." test-job: stage: test script: - echo "Running tests..." deploy-job: stage: deploy script: - echo "Deploying to production..."
The CI Lint tool (available in the GitLab UI under CI/CD > Pipelines > CI Lint) validates your .gitlab-ci.yml syntax before you commit, helping you catch configuration errors early.
More Related questions...