5

Based on below error message codedeploy copies my archive folder to some temp location. i can locate my archive.zip folder after deployment-archive folder.

The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "appspec.yml". The revision was unpacked to directory "/opt/codedeploy-agent/deployment-root/59a04892-4afd-4e82-9335-52e8b6047d4b/d-WZDFGDBHU/deployment-archive", and the AppSpec file was expected but not found at path "/opt/codedeploy-agent/deployment-root/59a04892-4afd-4e82-9335-52e8b6047d4b/d-WZDFGDBHU/deployment-archive/appspec.yml". Consult the AWS CodeDeploy Appspec documentation for more information at AWS website

but it looks appspec.yml immediately after deployment-archive folder. But its located deployment-archive/archive/appspec.yml

appspec.yml and my war file all zipped in S3

how to resolve this issue?

James Z
  • 12,209
  • 10
  • 24
  • 44
sam
  • 195
  • 2
  • 13

7 Answers7

7

I also encountered this because I found that CodeDeploy was filling up disk space with logs/deploy info at "/opt/codedeploy-agent/deployment-root/#####yourNumberWillBeDifferent#####". I had deleted all the directories in this location and on the very next deploy I experienced this issue. I found that if you keep the latest directory in this location then you will not get the error. What I wound up doing is have a script run every hour that deletes all the directories in this location except the latest one.

You probably deleted the the folder "d-WZDFGDBHU". CodeDeploy looked at the logs/info from the very last deployment it did on the instance and uses some info from there but could not find it. That is why it mentioned -

''' The revision was unpacked to directory "/opt/codedeploy-agent/deployment-root/59a04892-4afd-4e82-9335-52e8b6047d4b/d-WZDFGDBHU/deployment-archive", and the AppSpec file was expected but not found at path "/opt/codedeploy-agent/deployment-root/59a04892-4afd-4e82-9335-52e8b6047d4b/d-WZDFGDBHU/deployment-archive/appspec.yml" ''' d-WZDFGDBHU is the Deployment ID of the last deployment that was performed prior to the one you just tried.

I don't know why CodeDeploy needs to refer to the last deployment but indeed it does!!

Note that this only happens on in place deployments - not blue green.

I also discovered this -

CodeDeploy keeps a number of the last deployments to allow you to rollback to previous versions. By default it keeps the last 5 but this is configurable using the codedeploy agent config: https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-agent-configuration.html

The setting that controls this is :max_revisions:

ErnieAndBert
  • 1,344
  • 3
  • 21
  • 43
  • 4
    So.. buddy... what did you do to fix it? – Dave Mar 05 '21 at 20:43
  • 1
    To fill in a couple of blanks here: CodeDeploy wants to run the ApplicationStop step for the _previous_ deployment, not the new one - which makes sense if you think about it. It therefore looks for the AppSpec file that it used on the previous deployment to find that step. The workaround is simply to put an AppSpec in the exact path specified in the error message, with any required commands in the ApplicationStop step. – IMSoP Jun 30 '21 at 10:18
5

Found the issue.Instead of selecting appec.yml , myapp file and zipping them,i created folder for them and then created zip file. I should have created zip file just by selecting files, without creating folder for them. Wasted lot of time on this issue :(

sam
  • 195
  • 2
  • 13
2

I also encountered this issue under copydeploy which keeps failing code pipeline deployment. "The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "appspec.yml".

Steps i took: 1) Copy the appspec.yml from the AWS test template and use that to modify to a new appspec.tml

2)Remember to zip the file within the folder itself (not to create a folder with the files and zip it)

ak86
  • 41
  • 1
  • 4
0

You might see this error when we have CodeDeploy scripts have issues. so please check the CodeDeploy logs for errors in the deployment server.

If its Linux server:

/opt/codedeploy-agent/deployment-root/CodeDeploy<DEPLOYMENT-GROUP-ID><DEPLOYMENT-ID>/logs/script.log

If its windows server:

C:\temp\CodeDeploy\b394d44e-ca20-4956-a3ba-d90b99afa87f\d-1K1K9PR1D\logs\scripts.log
Aditya Y
  • 651
  • 6
  • 12
0

as experienced sometime the file located in different deployment file as example the codedeploy created and saved the deployment in the folder d-ERABTKHGF in the server but looking for the folder d-G9EZDPEGF.

The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "appspec.yml". The revision was unpacked to directory "/opt/codedeploy-agent/deployment-root/56474d41-fa14-41e0-9018-1bef9db19995/d-G9EZDPEGF/deployment-archive", and the AppSpec file was expected but not found at path "/opt/codedeploy-agent/deployment-root/56474d41-fa14-41e0-9018-1bef9db19995/d-G9EZDPEGF/deployment-archive/appspec.yml". Consult the AWS CodeDeploy Appspec documentation for more information at http://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file.html.

And if you navigate to the server

total 0
drwxr-xr-x 2 root root 6 Jan 18 10:57 d-ERABTKHGF
[root@ip-173-31-56-188 d-ERABTKHGF]# pwd
/opt/codedeploy-agent/deployment-root/56474d41-fa14-41e0-9018-1bef9db19995/d-ERABTKHGF

Solution : navigate to the /opt/codedeploy-agent/ and remove all the folder and the files within that folder.

0

The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "appspec.yml". The revision was unpacked to directory "/opt/codedeploy-agent/deployment-root/59a04892-4afd-4e82-9335-52e8b6047d4b/d-WZDFGDBHU/deployment-archive", and the AppSpec file was expected but not found at path "/opt/codedeploy-agent/deployment-root/59a04892-4afd-4e82-9335-52e8b6047d4b/d-WZDFGDBHU/deployment-archive/appspec.yml". Consult the AWS CodeDeploy Appspec documentation for more information at AWS website

I ran into this issue after deleting the directory the error message is referring to inside of the deployment-root directory.

I took a look at the directories inside of deployment-root and found a directory called deployment-instructions. Inside this directory I found two files <<fingerprint>>_last_successful_install and <<fingerprint>>_most_recent_install.

I renamed these two files to <<fingerprint>>_last_successful_install.old and <<fingerprint>>_most_recent_install.old.

After doing this I re-ran my deployment and it generated the files again, but this time with the new deployment version instead of the old one (d-WZDFGDBHU in your case).

Josh
  • 91
  • 5
0

Two things cause this issue

  1. If you deployed the scripts on asg or ec2 and then add additional scripts for the hook.
    For this you need to restart the asg or ec2 before adding additional scripts.

  2. If you used the same pipeline name again for a different deployment.
    For this you need to delete the input artifact that is in s3 before running the deployment since aws will not delete the artifacts even if you delete the pipeline.