17/12/2024

gitlab-ci: gitlab templates

Gitlab bazi isleri kendisi sunuyor ve bunlari cok kolay import edebiliyoruz.

include:
  - template: Terraform.latest.gitlab-ci.yml

bu include ile

https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml
adresinde ki template i getiriyor.

Hic kullanmasak bile ayni stage isimleri kullanmak zorundayiz. Template teki job larin hepsi (eger rule konmadiysa vs) calisiyor. Template deki stage i atlayamiyorsun ya hata veriyor ya calisiyor.

sadece gerekirse ayni job i tanimlayip degiskenleri editleyebiliyorsun.

Bizim job asagida ki gibi görünürken


build:
  artifacts:
    public: false
    paths:
      - terraform/plan.cache
    reports:
      terraform: terraform/plan.json

Templatede ayni kisim

artifacts:
    # Terraform's cache files can include secrets which can be accidentally exposed.
    # Please exercise caution when utilizing secrets in your Terraform infrastructure and
    # consider limiting access to artifacts or take other security measures to protect sensitive information.
    #
    # The next line, which disables public access to pipeline artifacts, is not available on GitLab.com.
    # See: https://docs.gitlab.com/ee/ci/yaml/#artifactspublic
    public: false
    paths:
      - ${TF_ROOT}/plan.cache
    reports:
      terraform: ${TF_ROOT}/plan.json