gpt4 book ai didi

git - 如何使用 Ansible git 模块克隆一个空的裸存储库?

转载 作者:太空狗 更新时间:2023-10-29 13:59:07 24 4
gpt4 key购买 nike

我有一个空的裸存储库,我正在尝试使用 Ansible 克隆它,但是 git 模块正在尝试 check out master 并因此失败,因为在一个空的 repo 中没有这样的 refspec .

我实现此功能的唯一方法是使用 shell 命令来克隆存储库。

最佳答案

我尝试了各种方法,唯一可行的方法是添加 ignore_errors: true 并检查导致 Ansible 模块失败的原因。我知道它不是最优的,但它有效,我们不会让所有错误通过:

- git: repo=<YOUR REPO> dest=<DEST>
ignore_errors: true
register: output
- name: check the error that failed the git module
fail: msg="{{ output.msg }}"
when: "'Failed to checkout branch master' not in output.msg"

顺便说一句,我过滤了 output.msg 而不是 output.stderr 因为出于某种原因,它会输出到 .msg code> 但不是 .stderr

关于git - 如何使用 Ansible git 模块克隆一个空的裸存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38169166/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com