Hello forks,
we are using terraform to deploy resource on cloud, we define stages in .gitlab-ci.yml file like
stages:
- sqlserver-plan
- sqlserver-deployment
- sqlserver-destroy
but we found a weird issue, on gitlab pipeline console, at each project’s destroy stage, the Mouse-On drop down window will show all the other projects’ destroy stage, what ever they are executed or not, see below screenshot
we put all projects ci stage in .gitlab-ci.yml file, an example code for 2 projects looks like below:
image: terraformci:3181211757
stages:
- plan
- deployment
- destroy
1_poc03:
stage: plan
variables:
WORKING_DIR: “projects/CHINA/poc03”
PLAN: $CI_COMMIT_SHA-$CI_PIPELINE_ID-poc03
script:
- terragrunt plan --terragrunt-working-dir $WORKING_DIR -out=plan.tfplan
- if [ find . -name plan.tfplan
];then mv find . -name plan.tfplan
$PLAN;else touch $PLAN;fi
tags:
- tencent-gitlab-runner-service-build
only:
variables:
- $CI_COMMIT_MESSAGE =~ /^deployment:poc03/
except:
- master
1_poc03_master:
stage: plan
variables:
WORKING_DIR: “projects/CHINA/poc03”
PLAN: $CI_COMMIT_SHA-$CI_PIPELINE_ID-poc03
script:
- terragrunt plan --terragrunt-working-dir $WORKING_DIR -out=plan.tfplan
- if [ find . -name plan.tfplan
];then mv find . -name plan.tfplan
$PLAN;else touch $PLAN;fi
tags:
- tencent-gitlab-runner-service-build
only:
changes:
- projects/CHINA/poc03/terragrunt.hcl
refs:
[“master”]
2_poc03_master:
stage: deployment
variables:
WORKING_DIR: “projects/CHINA/poc03”
PLAN: $CI_COMMIT_SHA-$CI_PIPELINE_ID-poc03
script:
- terragrunt apply --terragrunt-working-dir $WORKING_DIR --auto-approve
tags:
- tencent-gitlab-runner-service-build
when: manual
only:
changes:
- projects/CHINA/poc03/terragrunt.hcl
refs:
[“master”]
3_poc03_master:
stage: destroy
variables:
WORKING_DIR: “projects/CHINA/poc03”
PLAN: $CI_COMMIT_SHA-$CI_PIPELINE_ID-poc03
script:
- terragrunt destroy --terragrunt-working-dir $WORKING_DIR --auto-approve
tags:
- tencent-gitlab-runner-service-build
when: manual
only:
refs:
[“master”]
1_dmz_apim:
stage: plan
variables:
WORKING_DIR: “projects/CHINA/dmz_apim”
PLAN: $CI_COMMIT_SHA-$CI_PIPELINE_ID-dmz_apim
script:
- terragrunt plan --terragrunt-working-dir $WORKING_DIR -out=plan.tfplan
- if [ find . -name plan.tfplan
];then mv find . -name plan.tfplan
$PLAN;else touch $PLAN;fi
tags:
- tencent-gitlab-runner-service-build
only:
variables:
- $CI_COMMIT_MESSAGE =~ /^deployment:dmz_apim/
except:
- master
1_dmz_apim_master:
stage: plan
variables:
WORKING_DIR: “projects/CHINA/dmz_apim”
PLAN: $CI_COMMIT_SHA-$CI_PIPELINE_ID-dmz_apim
script:
- terragrunt plan --terragrunt-working-dir $WORKING_DIR -out=plan.tfplan
- if [ find . -name plan.tfplan
];then mv find . -name plan.tfplan
$PLAN;else touch $PLAN;fi
tags:
- tencent-gitlab-runner-service-build
only:
changes:
- projects/CHINA/dmz_apim/terragrunt.hcl
refs:
[“master”]
2_dmz_apim_master:
stage: deployment
variables:
WORKING_DIR: “projects/CHINA/dmz_apim”
PLAN: $CI_COMMIT_SHA-$CI_PIPELINE_ID-dmz_apim
script:
- terragrunt apply --terragrunt-working-dir $WORKING_DIR --auto-approve
tags:
- tencent-gitlab-runner-service-build
when: manual
only:
changes:
- projects/CHINA/dmz_apim/terragrunt.hcl
refs:
[“master”]
3_dmz_apim_master:
stage: destroy
variables:
WORKING_DIR: “projects/CHINA/dmz_apim”
PLAN: $CI_COMMIT_SHA-$CI_PIPELINE_ID-dmz_apim
script:
- terragrunt destroy --terragrunt-working-dir $WORKING_DIR --auto-approve
tags:
- tencent-gitlab-runner-service-build
when: manual
only:
refs:
[“master”]
how could it be happen and how to resolv it, thank