I am trying to execute a job on some pipeline variables. I have used 'rules' in my .gitlab-ci.yml file but getting the error "key may not be used with 'rules': only". How can I do this?
build-dev:
stage: build
only:
- master
- branches
rules:
- if: '$CI_COMMIT_BRANCH=="my-featured-branch"'
when : never
CodePudding user response:
The error you're receiving is literally what it says: you shouldn't use only
with rules
together in the same job.
Basically the reason is that this could lead into problems due to mixed behavior.
From the documentation:
rules
replacesonly
/except
and they can’t be used together in the same job. If you configure one job to use both keywords, the GitLab returns a key may not be used with rules error.