当存储库使用 LFS 时,如何在本地测试 gitlab runner 脚本
How can I locally test a gitlab runner script, when the repository uses LFS
我正在使用 GitLab runners,在推送之前必须在本地测试它们。
这可以使用
来完成
gitlab-runner exec docker testing
而且效果很好。
现在,如果存储库使用 LFS,这将不再有效,我会收到类似
的错误
batch request: missing protocol: "/home/self/workspace/project.git/info/lfs"
这似乎是因为如果使用 LFS,您不能将本地文件夹克隆到另一个文件夹。
使用 git clone --reference
suggested
有一个解决方法
但这如何应用于gitlab runner?
这个疯狂的黑客正在工作:
gitlab-runner exec docker testing --pre-clone-script 'set -x; function git {
if [[ "" == "clone" && "$@" != *"--help"* ]]; then
command git clone "" --reference https://user:password@git.example.com.de/path/to/repo.git "" "" ""
else
command git "$@"
fi
}'
你必须替换的地方
https://user:password@git.example.com.de/path/to/repo.git
通过本地存储库的原始 HTTP URL,包括用户名和密码。
这里发生了什么?
我们正在重新定义 git clone
命令,然后由 GitLab 运行程序执行并添加引用选项。克隆成功后,其余正常运行
我正在使用 GitLab runners,在推送之前必须在本地测试它们。
这可以使用
来完成gitlab-runner exec docker testing
而且效果很好。
现在,如果存储库使用 LFS,这将不再有效,我会收到类似
的错误batch request: missing protocol: "/home/self/workspace/project.git/info/lfs"
这似乎是因为如果使用 LFS,您不能将本地文件夹克隆到另一个文件夹。
使用 git clone --reference
suggested
但这如何应用于gitlab runner?
这个疯狂的黑客正在工作:
gitlab-runner exec docker testing --pre-clone-script 'set -x; function git {
if [[ "" == "clone" && "$@" != *"--help"* ]]; then
command git clone "" --reference https://user:password@git.example.com.de/path/to/repo.git "" "" ""
else
command git "$@"
fi
}'
你必须替换的地方
https://user:password@git.example.com.de/path/to/repo.git
通过本地存储库的原始 HTTP URL,包括用户名和密码。
这里发生了什么?
我们正在重新定义 git clone
命令,然后由 GitLab 运行程序执行并添加引用选项。克隆成功后,其余正常运行