16/71
Sign inSign up free

822. Replace only/except With rules in GitLab CI

hard 40 XP ~14 minHands-on lab

/home/student/repos/billing-service/.gitlab-ci.yml still uses only: and except:. The team switched to merge request pipelines, and the old conditions now run the wrong jobs: nightly never runs, and the default branch is about to be renamed, which would silently stop deploy.

Task

Rewrite the conditions with rules: only (no only: or except: left anywhere). Keep every job's stage and script.

JobMust run in
testevery pipeline except scheduled ones
docsmerge request pipelines (merge_request_event) that change a file under docs/ (at any depth)
deploypushes to the default branch only: not merge requests, tags or schedules. Don't hard-code the branch name.
nightlyscheduled pipelines only, and it is allowed to fail

The grader simulates pushes to the default branch and to a feature branch, merge requests with and without docs changes, a scheduled pipeline, a tag, and a project whose default branch is called trunk.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.