fix: .terraform-plan job
Compare changes
Files
2+ 7
− 0
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
GitLab has been upgraded. See what's new in the Changelog.
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.