使用Chef克隆空git repo
我正在使用Chef来启动由GIT存储库控制的新环境。在我的食谱中,我有一些代码,如:使用Chef克隆空git repo,git,amazon-web-services,chef-infra,aws-opsworks,Git,Amazon Web Services,Chef Infra,Aws Opsworks,我正在使用Chef来启动由GIT存储库控制的新环境。在我的食谱中,我有一些代码,如: begin git "#{current_release}/#{repo[:path]}" do repository repo[:repository] revision repo[:branch] action :sync end rescue nil end 当存储库中有内容时,这种方法效果很好,但当它为空时,我会得到一个Chef异常: C
begin
git "#{current_release}/#{repo[:path]}" do
repository repo[:repository]
revision repo[:branch]
action :sync
end
rescue nil
end
当存储库中有内容时,这种方法效果很好,但当它为空时,我会得到一个Chef异常:
Chef::Exceptions::UnsolvablegitReference:无法分析存储库中“master”的SHA引用
我知道我可以将某种类型的文件提交到回购协议中以避免这种麻烦,但这种解决方案有其自身的复杂性。当出现类似这样的异常时,有人能帮助使此代码“无声地失败”吗?基本上,如果git克隆不起作用,对我的应用程序来说也没什么大不了的
非常感谢任何提示!在AWS OpsWorks上使用Chef 11设置
ignore\u failure true
。这是一个适用于所有资源的解决方案
git "#{current_release}/#{repo[:path]}" do
repository repo[:repository]
revision repo[:branch]
action :sync
ignore_failure true
end
将
忽略故障设置为true
。这是一个适用于所有资源的解决方案
git "#{current_release}/#{repo[:path]}" do
repository repo[:repository]
revision repo[:branch]
action :sync
ignore_failure true
end