Google Cloud Build - 无法更新子模块
Google Cloud Build - Cant Update Submodules
我配置了 google 云构建 (GCB) 来触发我在 Github 中的一个存储库上的构建。此存储库需要另一个 git 存储库才能构建。这个另一个存储库是使用 git 子模块配置的。
我搜索了一下,目前看来 GCB 不支持子模块。所以我试图在 GCB 下载的源代码上手动 运行 git submodule update --init
,但是上面没有 .git
目录,命令失败。
我在这里错过了什么?
我正在使用这个问题作为参考:https://github.com/GoogleCloudPlatform/cloud-builders/issues/435
如果使用 github 触发您的构建,它将无法工作,因为缺少 .git 文件夹。为了使其正常工作,所有存储库都需要由 Cloud Source Repositories 进行镜像。然后,子模块可以这样更新:
- name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
args:
- '-c'
- |
git config -f .gitmodules submodule.[my-sub-repo-name].url https://source.developers.google.com/p/[my-project]/r/github_[my-sub-repo-name]
git submodule init
git submodule update
参考:https://github.com/GoogleCloudPlatform/cloud-builders/issues/26
有时您会收到 GIT_DISCOVERY_ACROSS_FILESYSTEM
错误或缺少 .git
文件夹。以下对我有用:
- id: git-submodule
name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
env: ['GIT_DISCOVERY_ACROSS_FILESYSTEM=1']
args:
- '-c'
- |
git init
git config -f .gitmodules submodule.[my-sub-repo-name].url https://source.developers.google.com/p/[my-project]/r/github_[my-sub-repo-name]
git submodule init
git submodule update
对于像我这样在 Bitbucket 中使用子模块的人,运行 遇到与 Cloud Build 类似的问题:一旦将存储库镜像到 Cloud Source Repository,子模块 URL 就不允许有.git
扩展。
例如,对于 "submodules" 文件夹中的主存储库 https://source.cloud.google.com/Project_ID/main_repo 和子模块 a, b
,.gitmodules
配置可能类似于此
[submodule "submodules/a"]
path = submodules/a
url = ../a
[submodule "submodules/b"]
path = submodules/b
url = ../b
之前,我使用了 URL ../a.git
和 ../b.git
,它们在 Bitbucket 中工作正常,但在 Cloud Source Repository 中却不行。
我配置了 google 云构建 (GCB) 来触发我在 Github 中的一个存储库上的构建。此存储库需要另一个 git 存储库才能构建。这个另一个存储库是使用 git 子模块配置的。
我搜索了一下,目前看来 GCB 不支持子模块。所以我试图在 GCB 下载的源代码上手动 运行 git submodule update --init
,但是上面没有 .git
目录,命令失败。
我在这里错过了什么?
我正在使用这个问题作为参考:https://github.com/GoogleCloudPlatform/cloud-builders/issues/435
如果使用 github 触发您的构建,它将无法工作,因为缺少 .git 文件夹。为了使其正常工作,所有存储库都需要由 Cloud Source Repositories 进行镜像。然后,子模块可以这样更新:
- name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
args:
- '-c'
- |
git config -f .gitmodules submodule.[my-sub-repo-name].url https://source.developers.google.com/p/[my-project]/r/github_[my-sub-repo-name]
git submodule init
git submodule update
参考:https://github.com/GoogleCloudPlatform/cloud-builders/issues/26
有时您会收到 GIT_DISCOVERY_ACROSS_FILESYSTEM
错误或缺少 .git
文件夹。以下对我有用:
- id: git-submodule
name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
env: ['GIT_DISCOVERY_ACROSS_FILESYSTEM=1']
args:
- '-c'
- |
git init
git config -f .gitmodules submodule.[my-sub-repo-name].url https://source.developers.google.com/p/[my-project]/r/github_[my-sub-repo-name]
git submodule init
git submodule update
对于像我这样在 Bitbucket 中使用子模块的人,运行 遇到与 Cloud Build 类似的问题:一旦将存储库镜像到 Cloud Source Repository,子模块 URL 就不允许有.git
扩展。
例如,对于 "submodules" 文件夹中的主存储库 https://source.cloud.google.com/Project_ID/main_repo 和子模块 a, b
,.gitmodules
配置可能类似于此
[submodule "submodules/a"]
path = submodules/a
url = ../a
[submodule "submodules/b"]
path = submodules/b
url = ../b
之前,我使用了 URL ../a.git
和 ../b.git
,它们在 Bitbucket 中工作正常,但在 Cloud Source Repository 中却不行。