1

When I trigger via Jenkins (code deploy plugin), I get the following error -

 No such file or directory - /opt/codedeploy-agent/deployment-root/edbe4bd2-3999-4820-b782-42d8aceb18e6/d-8C01LCBMG/deployment-archive/appspec.yml

However, if I trigger deployment into the same deployment group via code deploy directly, and specify the same zip in S3 (obtained via Jenkins trigger), this step passes.

What does this mean, and how do I find a workaround to this? I am currently working on integrating a few things and so, will need to deploy via code deploy and via Jenkins simultaneously. I will run the code deploy triggered deployment when I will need to ensure that the smaller unit is functioning well.

Update

Just mentioning another point, in case it applies. I was previously using a different codedeploy "application" and "deployment group" on the same ec2 instances, and deplying using jenkins and code deploy directly as well. In order to fix some issue (not allowing to overwrite existing files due to failed deployments, allegedly), I had deleted everything inside the /opt/codedeploy-agent/deployment-root/<directory containing deployments> directory, trying to follow what was mentioned in this answer. However, note that I deleted only items inside that directory. Thereafter, I started getting this error appspec.yml not found in deployment archive. So, then I created a new application and deployment group and since then, I am working on it.

So, another point to consider is whether I should do some further cleanup, if the jenkins triggered deployment is somehow still affected by those deletions (even though it is referring to the new application and deployment group).

Community
  • 1
  • 1
Sandeepan Nath
  • 9,966
  • 17
  • 86
  • 144
  • Can you provide a list the contents of /opt/codedeploy-agent/deployment-root/edbe4bd2-3999-4820-b782-42d8aceb18e6/d-8C01LCBMG/deployment-archive please? – Rodrigo Murillo Aug 03 '16 at 14:35
  • @RodrigoM the directory `d-8C0‌​1LCBMG` is not present inside `/opt/codedeploy-agent/deployment-root/edbe4bd2-3999-4820-b782-42d8aceb18e6/` at all. This seems to be an old deployment ID, and every time I try to do a build from jenkins, it looks for this particular build. I am not sure why does it try to look for this when the appspec file is present in the zip archive. Is it possible that it is somehow unable to access the file in the applicationstop step and hence looking for in the archive? Or is it like the archive content is anyway looked at regardless of this? – Sandeepan Nath Aug 04 '16 at 06:50
  • Bingo. Please see my answer below. – Rodrigo Murillo Aug 04 '16 at 15:01

2 Answers2

5

As part of its process, CodeDeploy needs to reference previous deployments for Redeployments and Deployment Rollbacks operations. These references are maintained outside of the deployment archive folders. If you delete these archives manually as you indicate, then a CodeDeploy install can get fatally corrupted: the references left to previous deployments are no longer correct or consistent, and deploys will fail.

The best thing at this point is to remove the old installation completely, and re-install. This will allow the code deploy agent to work correctly again.

I have learned the hard way not to remove/modify any of the CodeDeploy install folders or files manually. Even if you change apps or deployment groups, CodeDeploy will figure it out itself, without the need for any manual cleanup.

Rodrigo Murillo
  • 13,080
  • 2
  • 29
  • 50
  • 1
    CodeDeployment host agent currently have 7 lifecycle events, while the ApplicationStop lifecycle refers to the last successful deployment archive. So if the last successful deployment archive is deleted, the current running deployment will fail. – binbinlu Aug 04 '16 at 18:33
  • Ok, I got it. I will uninstall codedeploy on these instances and then reinstall on them. However, won't those applications and deployment IDs will still persist on the aws console? Also, I had an impression that in order to install codedeploy on an instance, it needs to be done when the instance is brought up for the first time. I did not do the setup myself, so would like to validate what our setup team told. How do I proceed after the reinstallation? Do I create a new application and deployment group? – Sandeepan Nath Aug 05 '16 at 09:41
  • And finally, I just wanted to confirm if there is any such restriction imposed by codedeploy to overwrite files during deployment if there was a failed deployment before that? As mentioned in my update to the question, I was getting `File already exists at location` error and tried to delete contents of deployment-root. – Sandeepan Nath Aug 05 '16 at 10:16
  • Deleting all the code deploy related files and reinstalling solved the problem. – Sandeepan Nath Aug 08 '16 at 11:50
  • Please see if you can answer this new question I have http://stackoverflow.com/questions/38832762/deployment-failing-at-install-step-due-to-error-file-already-exists – Sandeepan Nath Aug 08 '16 at 15:12
0

In order to do a deployment, the bundle needs to contain a appspec.yml file, and the file needs to be put at the top directory. Seems the error message is due to the host agent can't find the appspec.yml file.

binbinlu
  • 416
  • 2
  • 5
  • I verified that the appspec.yml file is present in the S3 archive. Since it is present the deployment done by code deploy directly is able to do it successfully. I guess it has something to do with the jenkins triggered deployment not able to access the file. – Sandeepan Nath Aug 04 '16 at 06:38
  • @SandeepanNath Did you got solution ? – Ashish Karpe Sep 14 '17 at 08:10