Hands-on task
GitLab CI: rules/if condition
The project app (cloned to /root/app, the web sign-in is on the GitLab tab) already has CI: a lint job in the lint stage runs on every push. A runner is connected.
Add a unit job in the test stage to .gitlab-ci.yml: it runs the tests with python3 -m unittest -v, but only on the main branch — via rules with an if condition. Push to main and get a green pipeline with the unit job.
Then make sure the rule works: push the same commit to a new branch try-rules and look at its pipeline in GitLab — it must have only lint.
- gitlab ci
- rules
- ci_commit_branch
- conditional execution
- yaml