How to use git submodules with Bitbucket pipelines?
I'm using Bitbucket pipelines to build my project and I'm having issues pulling in my submodule, I'm probably not configuring the SSH keys correctly.
What I've done:
The build error:
Submodule 'dependencies/my-dependency' ([email protected]: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 '[email protected]:mycompany/my-dependency.git' into submodule path 'dependencies/my-dependency' failed
My yml file
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
                MyProject/.gitmodules with paths to submodules (the paths to the repos in you .gitmodules file should be in the [email protected]:....git format):[submodule "modules"]
    path = modules
    url = [email protected]:....git
[submodule "translations"]
    path = translations
    url = [email protected]:....git
now you need to add the ssh key to submodule repository
Found the solution. I had to add the ssh public key to the submodule repository under Settings / Access Keys not Settings / SSH Keys.
here is another example that
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
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With