fix: .terraform-plan job
Closes #95 (closed)
In expression
(terraform plan $TF_PLAN_ARGS -out=${TF_DATA_DIR}/${CI_COMMIT_REF_SLUG}-${DEPLOYMENT_ENVIRONMENT}.tfplan -detailed-exitcode && exit_code=$?) || exit_code=$?
the variable exit_code
is set in a sub-shell ( ( ... )
). Because of that, if actual exit code is zero, the following script can't use it. Example:
bash-5.2$ (terraform plan $TF_PLAN_ARGS -out=123.tfplan -detailed-exitcode && exit_code=$?)
bash-5.2$ echo $exit_code
bash-5.2$
A subshell inherits the environment of the parent shell, but its exit status and environment changes (like setting variables) do not persist back to the parent shell.
Edited by Dmitrii Unterov
Merge request reports
Activity
added issuetypeBug teamCloud workflowIn Progress labels
assigned to @du228
requested review from @rh841
mentioned in commit 2c2e0363
Please register or sign in to reply