[英]How to use git submodules with Bitbucket pipelines?
如何在 Bitbucket 管道中使用 git 子模块?
我正在使用 Bitbucket 管道来构建我的项目,但我在拉入我的子模块时遇到了问题,我可能没有正确配置 SSH 密钥。
我所做的:
构建错误:
Submodule 'dependencies/my-dependency' (git@bitbucket.org:mycompany/my-dependency.git) registered for path 'dependencies/my-dependency'
Cloning into 'dependencies/my-dependency'...
Warning: Permanently added the RSA host key for IP address '18.205.93.2' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Clone of 'git@bitbucket.org:mycompany/my-dependency.git' into submodule path 'dependencies/my-dependency' failed
我的yml文件
image:
name: myuser/my-image-name
username: $DOCKER_HUB_USERNAME
password: $DOCKER_HUB_PASSWORD
email: $DOCKER_HUB_EMAIL
pipelines:
branches:
pipelines-setup:
- step:
script:
- git submodule update --init
找到了解决办法。 我必须将 ssh 公钥添加到Settings / Access Keys
而不是Settings / SSH Keys
下的子模块存储库。
MyProject/.gitmodules
和子模块的路径:[submodule "modules"]
path = modules
url = git@bitbucket.org:....git
[submodule "translations"]
path = translations
url = git@bitbucket.org:....git
2.
现在您需要将 ssh 密钥添加到子模块存储库
这是另一个例子
image: atlassian/default-image:2
pipelines:
default:
- step:
deployment: production
script:
- git submodule update --recursive --init
- apt-get update && apt-get install -y zip
- zip -r Test.zip . -x bitbucket-pipelines.yml *.git*
- pipe: atlassian/bitbucket-upload-file:0.1.3
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
FILENAME: Test.zip
如果您在主存储库中初始化了一个子模块,那么您可以在 bitbucket 管道步骤脚本中添加此命令:
- git submodule update --init --recursive
无需使用 SSH 密钥方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.