'gitlab branch common name - pipeline should be run execpt none branch should not be run

I want to run pipeline specific branches in GitLab like the branch names are sprint_100, Sprint-1,SPRINT-202. How should I give commands in rules?

(/^SPRINT_[0-9]+\.[0-9]+$/)||(/^Sprint_[0-9]+\.[0-9]+$/)||(/^Sprint_[0-9]+\.[0-9]+$/)

I used this, but it doesn't work. Kindly help me to sort it out this. Thank you!



Solution 1:[1]

This rules clause should work for your example to run a pipeline only branch names like sprint_100, Sprint-1 or SPRINT-202.

The regex will match case-insensitive on branch names starting with 'sprint' followed by either '-' or '_' and an unlimited amount of digits.

I am no regex expert so this regex can likely be improved.

  rules:
    - if: '$CI_COMMIT_BRANCH =~ /^SPRINT[-_][0-9]+/i'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 danielnelz