The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "appspec.yml"

Viewed 4761

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?

5 Answers

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:

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 :(

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)

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

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.

Related