Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Chef克隆空git repo_Git_Amazon Web Services_Chef Infra_Aws Opsworks - Fatal编程技术网

使用Chef克隆空git repo

使用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

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

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