Capistrano 3删除.git文件夹 [英] Capistrano 3 removing .git folder

查看:60
本文介绍了Capistrano 3删除.git文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的代码使用git存储库来获取应用程序的版本(我们制作了类似{git-tag}-build{git-hash}的代码,并且我们使用Capistrano来部署我们的应用程序.

Our code uses the git repository in order to get the version of the app (we make something like {git-tag}-build{git-hash} and we're using Capistrano to deploy our application.

但是,使用Capistrano v3.0(由Jenkins运行),我发现git存储库已删除.

However, using Capistrano v3.0 (ran by Jenkins) I found that the git repository is removed.

我试图做出类似的事情:

I tried to make something similar to this:

namespace :environment do
    desc 'Copies .git folder'
    task :copy_git do
        on roles(:app) do
            within release_path do
                execute :mkdir, ".git"
                execute :cp, "-R * .git/"
            end
        end
    end
end

但是正如您可能理解的那样,这是行不通的.

But as you may understand, it doesn't work.

这是我遇到的问题:

Could not get version string (no version file and git describe failed).

Could not get version string (no version file andgit describefailed).

关于如何解决此问题或如何在release_path中包含.git文件夹的任何想法?关于版本控制的任何其他想法都是可以接受的.

Any idea on how to solve this or how to have the .git folder inside the release_path? Any other idea on versioning is acceptable.

推荐答案

缺少.git文件夹的原因是通过git archive | tar -xf进行了部署(简化).

The reason for the missing .git folder is that deployment happens via git archive | tar -xf (simplified).

部署后,release_path包含一个名为REVISION的文件,您可以在其中找到已部署代码的git哈希.您可以使用它来获取确切的修订版本.

Upon deployment, release_path contains a file called REVISION within which you can find the git hash of the deployed code. You can use this to get the exact revision.

我通常建议您在代码库中粘贴一个变量,以跟踪发行版本,例如1.0.0.这就是RubyGems模板的工作方式.这样,您的代码版本就不会与版本控制系统绑定.

I generally recommend that you stick a variable in your codebase to track the release version, e.g. 1.0.0. This is how the RubyGems template does it. This way, your code version isn't tied to your version control system.

希望这会有所帮助!

这篇关于Capistrano 3删除.git文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆