GitLab CI Beginner Quiz
30 questions on GitLab CI.
Question 1: What does CI/CD stand for?
- A. Code Integration / Code Deployment
- B. Continuous Integration / Continuous Deployment (or Delivery) β (correct answer)
- C. Constant Integration / Constant Development
- D. Collaborative Integration / Collaborative Design
Explanation: CI/CD is a method to frequently deliver apps to customers by introducing automation into the stages of app development.
Question 2: What is the primary purpose of GitLab CI/CD?
- A. To automatically build, test, and deploy code every time a commit is pushed β (correct answer)
- B. To host websites like WordPress
- C. To replace Git
- D. To design user interfaces
Explanation: GitLab CI/CD automates the software lifecycle, catching bugs early (CI) and releasing code quickly (CD).
Question 3: Which file is strictly required in the root of your repository to configure GitLab CI/CD?
- A. .github-ci.yml
- B. ci-config.json
- C. .gitlab-ci.yml β (correct answer)
- D. pipeline.xml
Explanation: GitLab looks specifically for the .gitlab-ci.yml YAML file to understand how your pipelines should run.
Question 4: What executes the jobs defined in the .gitlab-ci.yml file?
- A. GitLab Webhook
- B. GitLab Runner β (correct answer)
- C. GitLab Master
- D. GitLab Executor
Explanation: GitLab Runners are lightweight agents (running on servers or containers) that pick up jobs from GitLab, execute them, and send the results back.
Question 5: In GitLab CI, what is a "Pipeline"?
- A. A network connection to the database
- B. The top-level component of continuous integration, comprising Stages and Jobs β (correct answer)
- C. A file path
- D. A Git branch
Explanation: A Pipeline is the overarching sequence of tasks. When you push code, a Pipeline is triggered.
Question 6: In GitLab CI, what is a "Stage"?
- A. A specific script to run
- B. A grouping mechanism that dictates the order in which Jobs are executed β (correct answer)
- C. A testing framework
- D. A server environment
Explanation: Stages (like build, test, deploy) run sequentially. If the build stage fails, the test stage will not start.
Question 7: In GitLab CI, what is a "Job"?
- A. A grouping of stages
- B. The actual script/command executed by the Runner β (correct answer)
- C. A developer assigned to a task
- D. A physical server
Explanation: Jobs are the smallest execution units. Multiple jobs in the same stage run in parallel.
Question 8: How do you define the script a Job should run in .gitlab-ci.yml?
- A. Using the
execute: keyword
- B. Using the
run: keyword
- C. Using the
script: keyword β (correct answer)
- D. Using the
cmd: keyword
Explanation: The script keyword accepts an array of shell commands to be executed by the Runner.
Question 9: What does the image: keyword do in .gitlab-ci.yml?
- A. It uploads a profile picture
- B. It defines the Docker image that the GitLab Runner will use to execute the Job β (correct answer)
- C. It generates screenshots of the website
- D. It creates a backup image of the code
Explanation: If your job tests a Node.js app, setting image: node:18 ensures the Runner has Node 18 pre-installed.
Question 10: By default, what happens if a Job fails in the test stage?
- A. The pipeline skips to the
deploy stage
- B. The pipeline automatically fixes the code
- C. The pipeline fails immediately, and subsequent stages are not executed β (correct answer)
- D. The runner is deleted
Explanation: This is the core principle of CI/CD: broken code should never progress further down the pipeline.
Question 11: What are "Artifacts" in GitLab CI?
- A. Old, unused code files
- B. Files and directories created by a job (like a compiled binary) that are saved and passed to subsequent jobs β (correct answer)
- C. Corrupted Git branches
- D. The
.gitignore file
Explanation: Because each job usually runs in a fresh container, if Job 1 compiles an app, it must save the binary as an artifact so Job 2 can deploy it.
Question 12: How can you pass secret passwords or API keys to a GitLab pipeline safely?
- A. Hardcode them into
.gitlab-ci.yml
- B. Write them in a
.txt file and commit it
- C. Use GitLab CI/CD Variables stored in the project settings β (correct answer)
- D. Ask the Runner during execution
Explanation: Variables defined in the UI are securely injected into the Runner as environment variables, keeping them out of your public source code.
Question 13: What does the only: keyword do in a job definition?
- A. It restricts the job to only run under specific conditions, like only on the
main branch β (correct answer)
- B. It makes the job run only once ever
- C. It allows only one user to run the job
- D. It only runs if the previous job failed
Explanation: only: - main ensures that deployment jobs don't accidentally run when pushing to a feature branch.
Question 14: Which keyword defines the order of execution for the whole pipeline?
- A.
order:
- B.
sequence:
- C.
stages: β (correct answer)
- D.
flow:
Explanation: The stages array at the top of the YAML file dictates the global order (e.g., build, then test, then deploy).
Question 15: What does the before_script: keyword do?
- A. It runs after the job finishes
- B. It defines an array of commands that run before each job's
script commands β (correct answer)
- C. It pauses the pipeline
- D. It resets the Git history
Explanation: It is commonly used to install global dependencies or configure SSH keys needed by the main script.
Question 16: If two jobs are assigned to the exact same Stage (e.g., test_frontend and test_backend both in the test stage), how do they execute?
- A. Alphabetically
- B. The first one listed runs first
- C. They run in parallel at the same time (if multiple runners are available) β (correct answer)
- D. One runs, and the other is skipped
Explanation: GitLab CI maximizes efficiency by running jobs in the same stage concurrently.
Question 17: What is a "Shared Runner"?
- A. A runner that runs on a USB drive
- B. A runner provided by GitLab.com that is shared among all GitLab users to execute jobs β (correct answer)
- C. A runner that shares its code publicly
- D. A runner that only runs shared libraries
Explanation: Shared runners allow you to run pipelines immediately without having to configure your own server hardware.
Question 18: What does the allow_failure: true keyword do in a job?
- A. It intentionally crashes the runner
- B. It permits the job to fail without causing the entire pipeline to fail β (correct answer)
- C. It skips the job entirely
- D. It runs the job infinitely until it passes
Explanation: This is useful for experimental tests or non-critical code-quality checks where a failure shouldn't block deployment.
Question 19: How do you manually trigger a deployment job instead of having it run automatically?
- A. Unplug the server
- B. Use the
when: manual keyword in the job definition β (correct answer)
- C. Delete the job and rewrite it when needed
- D. Use the
only: manual keyword
Explanation: when: manual halts the pipeline at that job, requiring a human to click a "Play" button in the GitLab UI to proceed.
Question 20: What is "Continuous Deployment" (CD) as opposed to "Continuous Delivery"?
- A. Continuous Deployment means code is automatically pushed all the way to production without human intervention β (correct answer)
- B. Continuous Delivery automatically pushes to production
- C. Continuous Deployment requires a manual click
- D. They are exactly the same thing
Explanation: Delivery implies it is *ready* to deploy (awaiting a click). Deployment implies the system automatically deploys it if tests pass.
Question 21: What is GitLab "Cache" used for?
- A. Storing compiled artifacts for deployment
- B. Storing downloaded dependencies (like
node_modules or .m2) between pipeline runs to speed up execution time β (correct answer)
- C. Caching website HTML
- D. Hiding passwords
Explanation: Unlike Artifacts (which pass files between stages in the *same* pipeline), Cache passes files between entirely *different* pipeline runs to save download time.
Question 22: What does the tags: keyword do in a job definition?
- A. It adds SEO tags to the project
- B. It directs the job to run only on specific GitLab Runners that share those exact tags (e.g.,
tags: [windows]) β (correct answer)
- C. It creates a Git tag
- D. It colors the job in the UI
Explanation: If you have a macOS runner for building iOS apps, tagging the runner and the job with mac ensures the job routes to the correct machine.
Question 23: What is a "Pipeline Schedule" in GitLab?
- A. A calendar for the development team
- B. A feature that allows pipelines to run automatically at specific times (like a cron job), useful for nightly builds or cleanups β (correct answer)
- C. A history of past pipelines
- D. A time tracker for billing
Explanation: Scheduled pipelines are great for running heavy integration tests overnight.
Question 24: What does the keyword rules: replace in modern GitLab CI syntax?
- A.
script:
- B.
stages:
- C.
only: and except: β (correct answer)
- D.
image:
Explanation: rules: is the modern, highly flexible way to determine exactly when a job should or should not run using complex logic.
Question 25: If a pipeline is stuck in "Pending", what is the most likely reason?
- A. The code has syntax errors
- B. There are no available GitLab Runners capable of picking up the job β (correct answer)
- C. The
.gitlab-ci.yml file is missing
- D. GitLab is deleting the repository
Explanation: If a job requires a tag (like gpu-enabled) and no online runner has that tag, the job stays pending infinitely.
Question 26: What is "GitLab Auto DevOps"?
- A. A robot that writes code for you
- B. A collection of pre-configured CI/CD templates that automatically detect, build, test, and deploy your application without writing a YAML file β (correct answer)
- C. A plugin for VS Code
- D. A Git command
Explanation: If you don't provide a .gitlab-ci.yml, Auto DevOps uses Heroku buildpacks and Kubernetes to attempt to guess how to deploy your app.
Question 27: How can you use another YAML file inside your main .gitlab-ci.yml?
- A.
import:
- B.
require:
- C.
include: β (correct answer)
- D.
load:
Explanation: include: allows you to modularize complex pipelines by pulling in templates from other files or even other repositories.
Question 28: What does the needs: keyword do?
- A. Defines required environment variables
- B. Bypasses strict Stage ordering to allow a job to start the moment its specified dependencies finish, creating a Directed Acyclic Graph (DAG) β (correct answer)
- C. Requests a code review
- D. Installs packages
Explanation: Normally, a deploy job waits for the ENTIRE test stage to finish. needs: lets the frontend deploy instantly as soon as the frontend tests pass, ignoring the backend tests.
Question 29: What does the services: keyword do in a job?
- A. It bills your credit card
- B. It spins up additional Docker containers (like PostgreSQL or Redis) linked to the main job, perfect for integration testing β (correct answer)
- C. It sends an email notification
- D. It starts the runner service
Explanation: If your tests require a live database, services: - postgres:13 will provide one during the lifespan of that specific job.
Question 30: What is the CI_COMMIT_SHA predefined variable?
- A. A password for the runner
- B. A variable provided by GitLab representing the commit hash that the pipeline is currently building β (correct answer)
- C. The username of the person who pushed the code
- D. The name of the project
Explanation: GitLab injects hundreds of Predefined Variables into the runner. CI_COMMIT_SHA is commonly used to uniquely tag Docker images.