如何在Bitbucket管道中使用git子模块?

Ale*_*lla 2 git ssh git-submodules bitbucket-pipelines

如何在Bitbucket管道中使用git子模块?

我正在使用Bitbucket管道来构建我的项目,并且在子模块中遇到问题,我可能没有正确配置SSH密钥。

我所做的:

  1. 在我的计算机上创建了SSH密钥对。
  2. 将相同的密钥对粘贴到“设置/ 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
Run Code Online (Sandbox Code Playgroud)

我的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
Run Code Online (Sandbox Code Playgroud)

Nic*_*hek 9

  1. 您的源存储库应包含MyProject/.gitmodules带有子模块路径的文件:
[submodule "modules"]
    path = modules
    url = git@bitbucket.org:....git

[submodule "translations"]
    path = translations
    url = git@bitbucket.org:....git
Run Code Online (Sandbox Code Playgroud)

2.

  • 打开存储库你想在哪里运行管道
  • 打开设置
  • PIPELINES部分打开SSH 密钥
  • 点击生成密钥
  • 复制公开密钥

现在您需要将 ssh 密钥添加到子模块存储库

  • 打开子模块存储库
  • 打开设置
  • GENERAL部分打开访问键
  • 添加复制的 ssh 公钥


Ale*_*lla 6

找到了解决方案。我必须在Settings / Access Keys not 下将ssh公钥添加到子模块存储库中Settings / SSH Keys


Rak*_*age 5

这是另一个例子

  • 使用默认图像
  • 添加子模块
  • 仅压缩所需的文件并上传到 bitbucket download

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
Run Code Online (Sandbox Code Playgroud)