Here is my pipeline code for git lab
image: zenika/terraform-aws-cli:latest
stages: [stage_b, stage_c]
before_script:
- terraform init
- terraform validate
job1:
stage: stage_b
script:
- source destroyfile_status.txt
- echo $EXITCODE
- if [ $EXITCODE -eq 2 ]; then
terraform plan -out="planfile" -detailed-exitcode;
exit_status=$?;
VARIABLE_NAME="EXITCODE";
echo "$VARIABLE_NAME=$exit_status" > planfile_status.txt;
if [ $exit_status -eq 0 ]; then
echo " Apply ran not deploying the instance again";
elif [ $exit_status -eq 1 ]; then
echo "The Plan failed";
exit 1;
elif [ $exit_status -eq 2 ]; then
echo "the plan is successful";
terraform apply "planfile";
fi
else
echo "destroy job failed";
fi
rules:
- if: $MORNINGJOB == "morning"
job3:
stage: stage_c
script:
- sudo chmod +x destroy_instances.sh
- source createfile_status
- echo $EXITCODE
- if [ "$EXITCODE" -eq 2 ]; then
./destroy_instances.sh;
else
echo "create job failed";
fi
rules:
- if: $EVENINGJOB == "evening"
my pipeline fails right after planstep and not throwing any errors in the logs
“Saved the plan to: planfile
To perform exactly these actions, run the following command to apply:
terraform apply “planfile”
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1″
New contributor
Anil Eppakayala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.