【问题标题】:Using Chef to clone empty git repo使用 Chef 克隆空的 git repo
【发布时间】:2013-10-31 18:46:17
【问题描述】:

我正在使用 Chef 启动由 GIT 存储库控制的新环境。在我的食谱中,我有一些类似的代码:

begin
    git "#{current_release}/#{repo[:path]}" do
        repository repo[:repository]
        revision repo[:branch]
        action :sync
    end
rescue nil
end

当存储库有内容时,这很有效,但当它为空时 - 我得到一个 Chef Exception:

Chef::Exceptions::UnresolvableGitReference:无法解析存储库中“master”的 SHA 引用

我知道我可以将某种文件提交到 repo 以避免这个麻烦,但是这个解决方案有它自己的复杂性。当出现这样的异常时,任何人都可以帮助使此代码“静默失败”吗?本质上,如果 git clone 不起作用,那对我的应用程序来说没什么大不了的。

非常感谢任何提示!在 AWS OpsWorks 上使用 Chef 11

【问题讨论】:

    标签: git amazon-web-services chef-infra aws-opsworks


    【解决方案1】:

    设置ignore_failure true。这是所有资源的common attribute

    git "#{current_release}/#{repo[:path]}" do
        repository repo[:repository]
        revision repo[:branch]
        action :sync
        ignore_failure true
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-08
      • 2013-08-07
      • 1970-01-01
      • 2022-11-02
      • 2021-07-16
      • 1970-01-01
      相关资源
      最近更新 更多