admin管理员组

文章数量:1345016

There is a task that must be completed in a certain order. But for some reason the elements of the task are not completed in the correct order.

qa-test:job:
  stage: qa
  extends:
    - .rule:qa
    - .scripts:qa-vault-scripts
    - .scripts:qa-test:job
  tags:
    - $TAGS

I need "extends" to add scripts in the proper order. But why does it add them the other way around, first

scripts:qa-test:job

then

.scripts:qa-vault-scripts

Now scripts:qa-test:job is executed first, which causes errors due to insufficient number of parameters that are in the vault

There is a task that must be completed in a certain order. But for some reason the elements of the task are not completed in the correct order.

qa-test:job:
  stage: qa
  extends:
    - .rule:qa
    - .scripts:qa-vault-scripts
    - .scripts:qa-test:job
  tags:
    - $TAGS

I need "extends" to add scripts in the proper order. But why does it add them the other way around, first

scripts:qa-test:job

then

.scripts:qa-vault-scripts

Now scripts:qa-test:job is executed first, which causes errors due to insufficient number of parameters that are in the vault

Share edited 19 hours ago Gaël J 15.6k5 gold badges22 silver badges45 bronze badges asked 23 hours ago Антон ЧелышковАнтон Челышков 591 gold badge2 silver badges7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You cannot use extends to accumulate values of different parents.

For a given key, the "closest" value will be used.

For instance, if both .scripts:qa-vault-scripts and .scripts:qa-test:job define the script key, then the "closest" will win, that is the latest declared.


Reference documentation:

  • https://docs.gitlab/ci/yaml/#extends
  • https://docs.gitlab/ci/yaml/yaml_optimization/#merge-details

The algorithm used for merge is “closest scope wins”. When there are duplicate keys, GitLab performs a reverse deep merge based on the keys. Keys from the last member always override anything defined on other levels.


You can use anchors or !reference for more control.

本文标签: Calling scripts in gitlabciStack Overflow