我试图将一个相当复杂的管道与在不同环境中按顺序运行的多个作业组合在一起。这是为了在我们的基础设施上运行 Terraform 更改。作业序列应该在我们的infraci环境中自动运行,该环境仅通过 CI 推出,然后停止并需要单击按钮才能开始部署到具有实际(尽管是开发)用户的开发环境。当然,我不想一遍又一遍地编写相同的代码,因此我尝试尽可能保持干燥。这是我的gitlab-ci.yml:
---
# "variables" & "default" are used by all jobs
variables:
TF_ROOT: '${CI_PROJECT_DIR}/terraform'
TF_CLI_CONFIG_FILE: .terraformrc
AWS_STS_REGIONAL_ENDPOINTS: regional
AWS_DEFAULT_REGION: eu-west-2
ASG_MODULE_PATH: module.aws_asg.aws_autoscaling_group.main_asg
default:
image:
name: hashicorp/terraform:light
entrypoint: ['']
cache:
paths:
- ${TF_ROOT}/.terraform
tags:
- nonlive # This tag matches the group wide GitLab runner.
before_script:
- cd ${TF_ROOT}
# List of all stages (jobs within the same stage are executed concurrently)
stages:
- init
- infraci_plan
- infraci_taint
- infraci_apply …Run Code Online (Sandbox Code Playgroud)