Direkt zum Inhalt

Aws Deployment- BeforeInstall : Script does not exist at specified location:

1

Hi

Deploying node files to to ec2 without any build using code deployment

The appspec.yml is like below

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/html/myapi
    file_exists_behavior: OVERWRITE
permissions:
  - object: /
    pattern: "**"
    owner: ec2-user
    group: apache
hooks:
  BeforeInstall:
    - location: scripts/clean.sh
      timeout: 180
      runas: root
  AfterInstall:
    - location: scripts/installnpm.sh
      timeout: 180
      runas: ec2-user

I get errors from deployment for the newly created deployment (new repo , new deployment ,new pipeline)

Script does not exist at specified location: /opt/codedeploy-agent/deployment-root/deploymentgroup/deployid/deployment-archive/scripts/clean.sh

When I navigate to the folder /opt/codedeploy-agent/deployment-root/deploymentgroup/deployid/deployment-archive/scripts

I can the clean.sh file exits

#!/bin/bash
echo "Clean the folder before install.!"
sudo rm -rf cd /var/www/html/myapi

##Having no issues in my old deployments which is created 6 months/1 year before working good. Looks quite surprise how old deployment working fine without any script error.

Installed the new code-agent but again same error. Increased time out also but no working.

Thanks

gefragt vor einem Jahr423 Aufrufe
2 Antworten
0
  • Correct the clean.sh file path in appspec.yml and ensure it's relative to the root of your repo.
  • Fix the script command: Change sudo rm -rf cd /var/www/html/myapi to sudo rm -rf /var/www/html/myapi.

Make scripts executable:

bash
chmod +x scripts/*.sh
  • Check logs at /var/log/aws/codedeploy-agent/codedeploy-agent.log for more insights.

Related Document links:

EXPERTE
beantwortet vor einem Jahr
  • Thanks for the reply.

    Not working

  • ensure correct file path in appspec.yml: yaml files:

    • source: scripts/ destination: /home/ec2-user/scripts/ Update hooks with correct path: yaml

    BeforeInstall:

    • location: /home/ec2-user/scripts/clean.sh Restart CodeDeploy agent: bash

    sudo service codedeploy-agent restart Log script execution by adding: bash echo "Started..." >> /tmp/deploy.log

  • LifecycleEvent - BeforeInstall
    Script - scripts/clean.sh
    [stderr]bash: line 1: /opt/codedeploy-agent/deployment-root/1d92a9f-4e3b-a736-0794b8261319/d-X2H97/deployment-archive/scripts/clean.sh: cannot execute: required file not found />
    

    The script exits in the below folder

    /opt/codedeploy-agent/deployment-root/1d92a9f8-4e3b-a736-0794b8261319/d-X2H97/deployment-archive/scripts/

0

Does Codedeploy agent have rights to enter and operate the folder where the files are ?

EXPERTE
beantwortet vor einem Jahr
  • Yes pipeline role have all the roles necessary for s3,ec2 code deploy..etc

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.