Reputation: 195
I am trying to deploy some new code using aws codepipeline. The first time it works no problem, the second time the deployment fails because of existing files. How can I instruct my flow to overwrite existing files?
Error Message: The deployment failed because a specified file already exists at this location:
Upvotes: 0
Views: 895
Reputation: 540
I think the best way to deploy is to delete the project directory and kill the process before deploying. This let the state of the project directory keep pure and in sync with the original repository.
As you can see from this link(appspec.yml hooks for deploying to EC2), CodeDeploy download artifacts on Install
phase and we cannot access to that step. Install
phase comes after BeforeInstall
hook.
So you should delete the directory and kill the processes before
Install
phase to be executed.
hooks:
BeforeInstall:
- location: codedeploy-scripts/deleteAndKill.sh
# runas: root # this might be needed depending on your setting.
Define codedeploy-scripts/deleteAndKill.sh
properly and try running CodePipeline
and CodeDeploy
again.
P.S. Deleting the project directory and killing the processes are somewhat bothering. so once you use docker
, what you have to do is only docker stop {container name}
and docker run {image name}
.
Upvotes: 1