use_mr_plan option in validate-plan-apply template
Summary
When I use validate-plan-apply
with a use_mr_plan
option, I am expecting the pipeline to validate
-> plan
-> apply with the plan in the MR
. But seems this is not how it works now, at least for template validate-plan-apply
.
Steps to reproduce
include:
- component: $CI_SERVER_FQDN/cicd/cicd-components/opentofu/validate-plan-apply@3.7.0
inputs:
opentofu_version: 1.10.6
enable_id_tokens: false
root_dir: environments/uat
auto_define_backend: false
state_name: uat
job_name_prefix: "uat_"
use_mr_plan: true
post_mr_plan_comment: true
plan_rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "parent_pipeline"'
- if: '$CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
apply_rules:
- if: '$CI_COMMIT_BRANCH == "main"'
when: manual
- when: never
Example Project
What is the current bug behavior?
During a MR, in the build stage, the plan
job is skipped, and the fetch-mr-plan
is triggered
What is the expected correct behavior?
During a MR, in the build stage, the plan
job is triggered, and the plan is generated, then when the MR is finally merged, the apply
stage fetch the plan from the MR and apply.
Otherwise, the use_mr_plan
option in a validate-plan-apply
has no sense.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
https://gitlab.com/components/opentofu/-/blob/main/templates/validate-plan-apply.yml?ref_type=heads#L307 https://gitlab.com/components/opentofu/-/blob/main/templates/validate-plan-apply.yml?ref_type=heads#L345