CodeDeploy Pipeline Failures from appspec Missing Files

1

Here's my appspec.yml file:

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ec2-user/myapp
hooks:
  BeforeInstall:
    - location: scripts/remove_root_dir.sh
      timeout: 900
      runas: root
  ApplicationStart:
    - location: scripts/install_dependencies.sh
      timeout: 300
      runas: root
    - location: scripts/start_server.sh
      timeout: 300
      runas: root
  ApplicationStop:
    - location: scripts/stop_server.sh
      timeout: 300
      runas: root

Here's my stop_server.sh file under the scripts folder in my Angular root directory:

#!/bin/bash
isExistApp = `pgrep httpd`
if [[ -n  $isExistApp ]]; then
    service httpd stop        
fi

The error message that I get is "ScriptMissing" at the ApplicationStop step. The script is not missing. I stopped my codedeploy agent, tried to clear out the files under /opt/codedeploy-agent/deployment-root (but many were write protected), and restarted the codedeploy agent. No success after numerous attempts to get CodeDeploy to complete successfully. What should I do to get CodeDeploy working properly?"

  • I'm facing a similar issue. Here's my Appspec.yml:

    version: 0.0
    os: linux
    files:
      - source: /src/app.js
        destination: /webapps/app
    hooks:
      BeforeInstall:
        - location: scripts/test-script.sh "BeforeInstall"
      AfterInstall:
        - location: scripts/test-script.sh "AfterInstall"
      ApplicationStart:
        - location: scripts/test-script.sh "ApplicationStart"
    

    I clear out all references to previous deployments. I create a new deployment and run it. The error message I get is:

    scripts/test-script.sh "BeforeInstall" Script does not exist at specified location: /opt/codedeploy-agent/deployment-root/f533eddd-98eb-4276-9454-c657056ccd25/d-ZAJ4AH94G/deployment-archive/scripts/test-script.sh "BeforeInstall" View more.

    N.b. test-script.sh contains only echo $1. It's a test-file that I'll update once I have this deployment pipeline working sucessfully.

    My question is: How do I get the EC2 to run the scripts from my project's root directory, and not this /opt/codedeploy-agent/deployment-root/<deployment-id> directory?

AWS
asked 2 years ago87 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions