找到你要的答案

Q:Add sha to git commit or elastic beanstalk deploy

Q:添加沙Git提交或弹性魔豆部署

I'm deploying an application with elastic beanstalk, which has its own deploy tool. This tool takes the latest commit, creates a zip from it, and deploys that to the cloud. To verify the deploy on each server, I'd like it to be able to report its own SHA once it has been deployed. There are actually a few valid approaches:

  • Add SHA to current commit, with a git hook.
  • Alter the EB deploy scripts to include a specific uncommitted file, which can be easily created in a deploy script or git hook.
  • Make elastic beanstalk current application version label available to the instance.

我部署与弹性魔豆的一个应用,它有其自身的部署工具。本工具采用最新提交的,从它创建zip,并部署到云。要验证在每个服务器上的部署,我希望它能够报告自己的SHA一旦部署。实际上有一些有效的方法:

  • 添加沙目前的承诺,用git钩。
  • Alter the EB deploy scripts to include a specific uncommitted file, which can be easily created in a deploy script or git hook.
  • Make elastic beanstalk current application version label available to the instance.
answer1: 回答1:

I solved this with .gitattribtues export-subst. (http://git-scm.com/docs/gitattributes) This automatically adds the SHA to the repo when it is archived, which is what elastic-beanstalk does upon deploy.

My .gitattributes:

*.py diff=python
version.txt export-subst

My version.txt:

$Format:%H$

See http://stackoverflow.com/a/16365314/478354

我解决了这个。gitattribtues export-subst.(http://git-scm.com/docs/gitattributes)这个自动添加沙的回购时,存档,这就是弹性魔豆也在部署。

我gitattributes:

*.py diff=python
version.txt export-subst

我的version.txt:

$Format:%H$

看到http://stackoverflow.com/a/16365314/478354

answer2: 回答2:

Add SHA to current commit, with a git hook.

This doesn't seem practival, as it would change the commit (and its SHA1)!

So generating the right file based on the commit, at deploy time is usually the best practice.

添加沙目前的承诺,用git钩。

这似乎并不实际,因为它会改变提交(和SHA1)!

因此,在提交的基础上生成正确的文件,在部署时通常是最好的做法。

git  amazon-web-services  elastic-beanstalk