0
votes

I can run /opt/plesk/php/7.2/bin/php /usr/lib/plesk-9.0/composer.phar install manually on the instance and it executes well.

I get a successful deployment (Bitbucket pipelines > Codedeploy > Ec2) however, I get error in the /opt/codedeploy-agent/deployment-root/(deployment-group-id)/(deployment-id)logs/scripts.log

2020-10-15 14:47:04 [stderr]  The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly

after_install.sh

#!/bin/bash

# Copy source files to DEVELOPMENT environment
if [ "$DEPLOYMENT_GROUP_NAME" == "staging-deployment-group" ]; then
chown -R user:psacln /var/www/vhosts/example.com/code-deploy-temp
find /var/www/vhosts/example.com/code-deploy-temp -type f -not -name ".pl" -not -name ".cgi" -not -name "*.sh" -print0 | xargs -0 chmod 0644
find /var/www/vhosts/example.com/code-deploy-temp -type d -print0 | xargs -0 chmod 0755
shopt -s dotglob
rsync -avz /var/www/vhosts/example.com/code-deploy-temp/* /var/www/vhosts/example.com/staging.example.com/
rm -rf /var/www/vhosts/example.com/code-deploy-temp/*
cd /var/www/vhosts/example.com/staging.example.com/
/opt/plesk/php/7.2/bin/php /usr/lib/plesk-9.0/composer.phar install
fi

appspec.yml

version: 0.0
os: linux 
files:
  - source: /
    destination: /var/www/vhosts/example.com/code-deploy-temp
hooks:
  AfterInstall:
    - location: scripts/after_install.sh
      timeout: 300

Anyone may have experienced the same? Appreciate any inputs.

1
Have you tried seeting these env variables: HOME or COMPOSER_HOME? - Marcin

1 Answers

0
votes

Resolved this by adding:

export COMPOSER_HOME="$HOME/.config/composer";

before this line /opt/plesk/php/7.2/bin/php /usr/lib/plesk-9.0/composer.phar install