How to make AWS CodeDeploy return an error when some of the hooks applications fail?

I have AWS with two instances. I configured CodeDeploy to automatically deploy my project in all instances.

In appspec.ymlI have this section:

hooks:
   AfterInstall:
     - location: codedeploy_scripts/deploy_afterinstall
       timeout: 300
       runas: root

deploy_afterinstallis a simple bash script. Sometimes some of the teams in it fail. For example, this command that updates / installs the composer's dependencies.

if [ -f "composer.lock" ]; then
   composer update -n
else
   composer install -n
fi

But CodeDeploy ignores any errors in this script and always says that the deployment was successful. How can I change this behavior? I want the deployment to fail when some of the commands in the hook were not completed successfully and to see errors in the deployment console or log.

+4
2

CodeDeploy. bash :

#!/bin/bash
set -euo pipefail

e, u o pipefail, bash script. "Bash " .

, bash , .

+7

CodeDeploy script 'deploy_afterinstall', , . , , , script, "deploy_afterinstall". script .

+2

Source: https://habr.com/ru/post/1629093/


All Articles