EasyEnv
Engineering/Courses/Catalog/GitLab CI/Rules and Conditional Jobs
GitLab CI
IntermediateLesson 6 of 1130 min · hands-on

Rules and Conditional Jobs

Part of the GitLab CI course

Every job you have written so far runs on every single push, no matter which branch it landed on or why the pipeline started. That is harmless while you are experimenting alone, but it stops being harmless the moment a real team is pushing to a real project. Nobody wants a thirty minute integration suite kicking off because someone fixed a typo in the README.

Think of a rules: block as a series of yes-or-no questions asked in a fixed order, like a form that says "if you answered yes to question 1, stop here and follow its instructions, otherwise move to question 2." A rule in GitLab CI is exactly one entry in that list, and GitLab walks the list from the top, checking each rule in turn, and stops at the very first one that matches. ...

Want to learn GitLab CI Rules and Conditional Jobs in a real environment?

Click below, get a fresh Linux box with GitLab CI ready to go, and work through Rules and Conditional Jobs hands-on with an AI tutor that knows your code.

Start this lessonRules and Conditional Jobs

What you'll learn

  • Rules keyword
  • If conditions
  • CI_COMMIT_BRANCH
  • CI_PIPELINE_SOURCE
  • When manual
  • Changes paths
  • Rules vs only/except

Read this lesson in your language

All lessons in this course

11 lessons
  1. 1What Is CI/CD20 min
  2. 2Your First Pipeline25 min
  3. 3Jobs and Stages30 min
  4. 4Variables and Secrets30 min
  5. 5Artifacts and Caches30 min
  6. 6Rules and Conditional Jobs30 min
  7. 7Docker Jobs and Services35 min
  8. 8Environments and Deployments30 min
  9. 9Includes and Templates30 min
  10. 10Runners30 min
  11. 11Capstone: Build, Test, Deploy60 min

Explore other courses

Rules and Conditional Jobs - GitLab CI (English) | Engineering Courses