gitlabci
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| gitlabci [2021/07/12 10:29] – created skipidar | gitlabci [2022/09/22 16:35] (current) – skipidar | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| .gitlab-ci.yml | .gitlab-ci.yml | ||
| - | <code> | + | |
| + | <sxh yaml> | ||
| stages: | stages: | ||
| - deployless-test | - deployless-test | ||
| Line 85: | Line 86: | ||
| include: .gitlab-ci-deployto.yml | include: .gitlab-ci-deployto.yml | ||
| strategy: depend | strategy: depend | ||
| - | </code> | + | </sxh> |
| .gitlab-ci-test-deployless.yml | .gitlab-ci-test-deployless.yml | ||
| - | <code> | + | <sxh yaml> |
| # no reason to run on launch-hub runner. Only required, when assuming IAM roles into the account. | # no reason to run on launch-hub runner. Only required, when assuming IAM roles into the account. | ||
| Line 167: | Line 168: | ||
| - echo "This job does UI tests on STAGE." | - echo "This job does UI tests on STAGE." | ||
| - | </ | + | </sxh> |
| + | |||
| + | |||
| + | === hide a job (.job) === | ||
| + | Start the job name with a dot (.) and it is not processed by GitLab CI/CD | ||
| + | https:// | ||
| + | |||
| + | <sxh yaml> | ||
| + | | ||
| + | name: hashicorp/ | ||
| + | | ||
| + | - '/ | ||
| + | - ' | ||
| + | </ | ||
| + | |||
| + | |||
| + | === includes of another files === | ||
| + | |||
| + | You can include | ||
| + | - from a subfolder | ||
| + | - from another gitlab-repository using " | ||
| + | |||
| + | <sxh yaml> | ||
| + | include: | ||
| + | - gitlab_pipeline_jobs/ | ||
| + | - gitlab_pipeline_jobs/ | ||
| + | - project: " | ||
| + | ref: master | ||
| + | file: " | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | === extends: syntax === | ||
| + | You can use the " | ||
| + | when the included modules shouldnt be activated automatically. | ||
| + | |||
| + | Instead you should include those with customized variables. | ||
| + | |||
| + | https:// | ||
| + | |||
| + | <sxh yaml> | ||
| + | .tests: | ||
| + | script: rake test | ||
| + | stage: test | ||
| + | only: | ||
| + | refs: | ||
| + | - branches | ||
| + | |||
| + | rspec: | ||
| + | extends: .tests | ||
| + | script: rake rspec | ||
| + | only: | ||
| + | variables: | ||
| + | - $RSPEC | ||
| + | </ | ||
| + | |||
| + | |||
| + | === 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] | ||
| + | |||
| + | </sxh> | ||
gitlabci.1626085763.txt.gz · Last modified: by skipidar
