gitlabci
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
gitlabci [2022/09/22 14:19] – skipidar | gitlabci [2022/09/22 16:35] (current) – skipidar | ||
---|---|---|---|
Line 229: | Line 229: | ||
=== extends: syntax === | === extends: syntax === | ||
+ | |||
+ | |||
+ | === <<: *my_anchor reuse properties with anchors === | ||
+ | Using anchors you can reuse attriburtes across jobs, | ||
+ | especially from a disabled job: | ||
+ | |||
+ | <sxh yaml> | ||
+ | |||
+ | .deployment: | ||
+ | image: path/ | ||
+ | tags: | ||
+ | - LAUNCHTAG | ||
+ | |||
+ | |||
+ | .deploy_to_prod: | ||
+ | <<: *deployment | ||
+ | variables: !reference [.env_variables, | ||
+ | |||
+ | .deploy_to_prodint: | ||
+ | <<: *deployment | ||
+ | variables: !reference [.env_variables, | ||
+ | | ||
+ | </ | ||
+ | |||
+ | |||
+ | === !reference [.terraform, | ||
+ | Reference some piece of code. | ||
+ | https:// | ||
+ | |||
+ | Use the !reference custom YAML tag to select keyword configuration from other job sections and reuse it in the current section. | ||
+ | |||
+ | Unlike YAML anchors, you can use `!reference` tags to reuse configuration from included configuration files as well. | ||
+ | |||
+ | |||
+ | setup.yml | ||
+ | |||
+ | <sxh yaml> | ||
+ | |||
+ | .setup: | ||
+ | script: | ||
+ | - echo creating environment | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | gitlab-ci.yml | ||
+ | <sxh yaml> | ||
+ | include: | ||
+ | - local: setup.yml | ||
+ | |||
+ | .teardown: | ||
+ | after_script: | ||
+ | - echo deleting environment | ||
+ | |||
+ | |||
+ | test: | ||
+ | script: | ||
+ | - !reference [.setup, script] | ||
+ | - echo running my own command | ||
+ | after_script: | ||
+ | - !reference [.teardown, after_script] | ||
+ | |||
+ | </ | ||
gitlabci.1663856347.txt.gz · Last modified: by skipidar