Skip to content

Improve syntax for variables expressions in 'only' and 'except': not equal

Description

GitLab CI has basic support for variables expressions in only and except keyworks. Consider additional improvements that are useful for real world use cases and implement them.

Proposal

Support for != and !~ operators. They will check whether the rhs string or regex does not match the lhs variable.

I would also hope that you would allow look-ahead assertions in the regex (which currently gets flagged as an invalid expression).

Example

!=

variables:
- $CI_COMMIT_REF_NAME != "master"

!~

variables:
- $CI_COMMIT_REF_NAME !~ /^v[0-9]/

negative look-ahead (which could serve as a workaround for the lack of !=)

variables:
- $CI_COMMIT_REF_NAME =~ /^(?!master$)./