部署期间的AWS Codedeploy git修订版
问题描述:
我正在使用AWS CodeDeploy服务进行一些测试,并设法从github部署了我的应用程序,到目前为止一切顺利.
I am running some test with AWS CodeDeploy service and managed to deploy my app from github, so far so good.
但是现在我需要在AfterInstall挂钩中部署git版本.有没有办法得到git版本?
But now I need to git revision that is deployed in the AfterInstall hook. Is there a way to get the git revision?
已经查看了部署-归档目录,但是由于没有.git目录,因此该代理似乎正在执行git导出.
Already looked in the deployment-archive dir but it looks like the agent is doing a git export since there is no .git directory.
答
要部署特定的修订版,您必须从CodeDeploy中提取部署详细信息,因为它目前尚未公开给钩子脚本.
To get the specific revision deployed, you'll have to pull the deployment details from CodeDeploy as it's not currently exposed to hook scripts.
- 使用DEPLOYMENT_ID环境变量(由主机代理设置)获取部署ID.
- 使用部署ID调用 GetDeployment .
- 在响应结构中,从Revision-> GitHubLocation-> CommitID 中获取GitHub提交ID.
- Use the DEPLOYMENT_ID environment variable (set by the host agent) to get the deployment id.
- Call GetDeployment with the deployment id.
- In the response structure get the GitHub commit id from Revision -> GitHubLocation -> CommitID