Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

config key may not be used with `rules`: except. Gitlab CI

I have the following job in the pipeline, which I want to be run only on the master branch

docker:build-production:
  extends:
    - .docker:build
    - .aws-production-variables
  rules:
    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      when: never

but I get the following error:

jobs:docker:build-production config key may not be used with `rules`: except

I don't have the except keyword anywhere, so I'm not sure why I'm getting this error.

Edit: For more context, it was failing because docker:build-production: job was inheriting from the .docker:build which had except clause in it. I should've used either rules or only and except in both of them for it to properly work.

like image 727
indee423 Avatar asked Oct 21 '25 03:10

indee423


1 Answers

Due to the extends keyword, you reuse two configuration sections. These sections probably contain only and except keywords, which cannot be used together with rules. If you had control over them, you could transition them to use the rules keyword and stick with the extract you posted.

I have not found this in the official documentation, only in some discussions, as here.

like image 75
Daniel Avatar answered Oct 24 '25 03:10

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!