FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects

fix: .terraform-plan job

Merged Dmitrii Unterov requested to merge 95-fix-tf-plan-job into master

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading