Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,730
Community Members
 
Community Events
176
Community Groups

How to use git submodule init property?

I have a submodule in my git (private repository, located in bitbucket as well) and I want to load it in the pipelines but I get the error:

fatal: could not read Username for 'https://bitbucket.org': No such device or address

Now, obviously, the error occurs because I didn't set user and password and my question is how can I do it properly assuming that we use with our submodules

Thanks 

 

1 answer

1 accepted

1 vote
Answer accepted

Hi @Aharono,

If you want to use HTTPS, you can create and use repository variables for the username and password. I strongly recommend generating an app password for your Bitbucket account with permissions "Repositories : Read" only, and use that app password instead of your account's password.

After you generate the app password, open in Bitbucket website the repo that has the submodule. Select Repository settings > Repository variables and create one variable for your Bitbucket username and another one for the app password.

Please make sure that the variable for the app password is marked as Secured, so that its value won't appear in the Pipelines log. You can also make the username variable Secured if you don't want your username to be visible in the Pipelines log.

Let's say the variables are named BB_username and BB_password. Then, in your bitbucket-pipelines.yml file you can add the following commands:

- git config submodule.<my-submodule>.url https://${BB_username}:${BB_password}@bitbucket.org/<workspace-id>/<submodule-repo>.git
- git submodule init
- git submodule update

where
<my-submodule> replace with the name of the submodule, as defined in the .gitmodules file
<workspace-id> replace with the workspace id that owns the submodule
<submodule-repo> replace with the repo slug for the submodule repo

 

Please keep in mind though that even secured variables can be retrieved by all users with write access to a repository. If other users have write access to these two repos and you'd like to avoid that, another option would be to use SSH instead of HTTPS.

In order to set this up, open in Bitbucket website the repo that has the submodule. Select Repository settings > SSH keys and then select Generate keys to generate an SSH key pair for Pipelines in this repo. Then, copy the public key.

Open the submodule repository on Bitbucket website, go to its Repository settings > Access keys and add there the public SSH key you copied before.

Afterwards, you can use the following commands in your yml file:

- git config submodule.<my-submodule>.url git@bitbucket.org:<workspace-id>/<submodule-repo>.git
- git submodule init
- git submodule update

Make the same replacements in the 'git config' command as I mentioned earlier.

Please feel free to let me know if this works for you and if you have any questions.

Kind regards,
Theodora

For me, it works perfectly. Thanks :)

Like Theodora Boudale likes this

That's good to hear, you are very welcome @mostafakamal

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events