【问题标题】:Chef git resource always fails with "STDERR: fatal: Cannot force update the current branch"Chef git 资源总是失败并显示“STDERR:致命:无法强制更新当前分支”
【发布时间】:2016-02-18 15:20:10
【问题描述】:

作为我的 Chef 食谱中的步骤之一,我需要从 github 签出一些代码。但是每次我执行 chef-client 时,它都会失败并显示以下输出:

Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
---- Begin output of git branch -f master 276d62661678d9249d7cafbc7dbbc50a94d212bc ----
STDOUT: 
STDERR: fatal: Cannot force update the current branch.
---- End output of git branch -f master 276d62661678d9249d7cafbc7dbbc50a94d212bc ----
Ran git branch -f master 276d62661678d9249d7cafbc7dbbc50a94d212bc returned 128
[2016-02-18T00:46:11+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

我尝试将资源操作从 :sync 更改为 :checkout 我还尝试在运行配方之前删除源文件夹。

配方代码:

git "/tmp/node_exporter" do
    repository 'https://github.com/prometheus/node_exporter.git'
    checkout_branch 'master'
    action :sync
end

repo 似乎已被下载,所以有什么问题?为什么会出现此错误?

【问题讨论】:

  • 请附上您的食谱代码。我猜您已将 checkout_branch 设置为 master?
  • 添加了代码。是的,checkout_branch 设置为 master。

标签: git chef-infra


【解决方案1】:

你想让它阅读

git "/tmp/node_exporter" do
    repository 'https://github.com/prometheus/node_exporter.git'
    revision 'master'
    action :sync
end

checkout_branch 是另一回事,它是您不需要经常触摸的超级高级功能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    • 2018-02-14
    相关资源
    最近更新 更多