Fix regular expression for commit message containing -draft
What does this MR do and why?
Fix the documentation on https://docs.gitlab.com/ee/ci/yaml/workflow.html where it said that the regular expression /-draft$/ would match commits that contain -draft. I think the expression should instead be /-draft/ (without the $).
Screenshots or screen recordings
When using the old regex with /-draft$/, jobs are run for all commits, even if they do contain -draft:
With the updated regex (without the $), commits that contain -draft don't create jobs:

How to set up and validate locally
- Create a new
.gitlab-ci.ymlfile in a repository. - Add the following contents to the file:
workflow:
rules:
- if: $CI_COMMIT_MESSAGE =~ /-draft/
when: never
- when: always
publish:
image: node:latest
stage: deploy
script: echo "Hello"
- Commit your changes.
- Create another commit with a commit message containing
-draftand push. - Check in Gitlab whether your pipeline has been run for the new commit. It should not have been run.
- Create another commit that doesn't contain
-draft, push and check whether your pipeline has been run. It should have run.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Dean Malan
