You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
you'll need to reconfigure the git remote to pull from Bitbucket. Pipelines uses an O-auth token to do the initial cloning which is then destroyed immediately afterwards.
First you'll want to create an app-password for the user who's going to access the submodules (App passwords are here in Bitbucket Cloud | Bitbucket Blog). This will ensure you can work with 2fa enabled on the account.
Then you'll need to provide the username and app-password as Bitbucket Pipelines variables (https://confluence.atlassian.com/display/BITBUCKET/Environment+variables+in+Bitbucket+Pipelines)
assuming you've named them
PASSWORD, add this step to the start of your pipeline:
git remote set-url origin https://$USERNAME:$PASSWORD@bitbucket.org/team/repo.git
followed by initialising your submodules
git submodule update --init
Hi I have tried 20+ times but until the `git submodule update --init` step, it always said:
+ git submodule update --init Submodule 'dev/scripts/api' (email@example.com:team/services.git) registered for path 'dev/scripts/api' Cloning into 'dev/scripts/api'... Warning: Permanently added 'bitbucket.org' (RSA) 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. fatal: clone of 'firstname.lastname@example.org:team/services.git' into submodule path 'dev/scripts/api' failed
Anyone has experienced this?
just spent a whole afternoon looking into this... the answer provided by Jacob Ideskog does work. However, one important point is to make sure the module url in`.gitmodules` is something like email@example.com:XXXX but not using https:. Only when it's set toSSH it will pick up the public key you generated and added to the submodule's repo. Otherwise, it will complain about either the username or password cannot be found.
Hope this helps
That isn't enough.
If your submodules point at an ssh Bitbucket url (firstname.lastname@example.org:org/repo.git), you need to change the url of the submodule as well. I did it like this:
git config --file=.gitmodules submodule.$SUBMODULENAME.url https://$USERNAME:$PASSWORD@bitbucket.org/org/repo.git
Then it's the standard git submodule update --init.
This feels like a massive missing feature in BB Pipelines and I hope it gets resolved in future updates!
I followed the steps shown on this: https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html
Managed to get the git submodule checkout working fine.
Only issue is, we use IP Whitelisting for our Bitbucket Account. When that is enabled, the submodule checkout fails!
Warning: Permanently added the RSA host key for IP address '126.96.36.199' to the list of known hosts.
To access this repository, an admin must whitelist your IP.
fatal: Could not read from remote repository.
I tried whitelisting this IP and a bunch of others that it uses, but no luck!
Anyone has managed to get a workaround for this?
I would also like to use a submodule in my pipeline.
The submodule has been initilaised, but unfortunately
git submodule update --init
fails with the error:
fatal: destination path '<pathToSubmodule>' already exists and is not an empty directory,
because during the build setup the node_modules were already loaded from the cache.
Is there a solution for this?