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,374
Community Members
 
Community Events
176
Community Groups

How can I access a private repo within a docker service container?

Edited

Hello

 

I am using a docker service in bitbucket-pipelines and calling composer from within that container. However, that container does not have permission to access private repositories in bitbucket.

 

Would I need to create a new user just for the CI with a private key to get this working or is there an easier way to link to the existing account?

1 answer

1 accepted

1 vote
Answer accepted

Hi @Antonios Pavlakis ,

If you only need to clone (and not push to) another private Bitbucket repo, you can set up Access keys.

Let's say you have repo-A and repo-B, Pipelines is running in repo-A and you want to clone repo-B.

  1. In Bitbucket website, go to repo-A's Repository settings > SSH keys
  2. In that page you can generate an SSH key pair
  3. Copy the public SSH key
  4. Go to repo-B's Repository settings > Access keys
  5. Add there the public key you copied before

You will then be able to clone repo-B from Pipelines builds running in repo-A via SSH. You will need to have admin permissions to both repos to access their Repositories settings page.

Access keys give read-only access, so if you also need to push to repo-B, you'll need a different approach.

If you don't want to tie authentication to a certain user, you can set up OAuth:

If the repos don't belong in the same workspace, you'll need to generate an OAuth consumer in the workspace that owns repo B. You'll need to have admin permissions in the workspace to do that.

Please note that the script in the documentation above is for pushing back to the same repo where Pipelines is running. If you want to push to a different repo, you can adjust the URL in the example to be the one of repo-B and use that URL in the push command (no need to change origin).

I hope this helps, please feel free to let me know if you have any questions.

Kind regards,
Theodora

Hi,

 

This is a bit old now, but just pointing out that I was looking for a solution for the same problem.

The real problem is that the pipeline is fetching the repo, it's the docker image builder (another vm) that is doing that.

So far, the solutions I have run across are either using buildkit (not yet supported by bitbucket pipelines) or by passing the private and public key as variables and setting them in the .ssh dir of your user. 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events