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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bitbucket Pipeline - Pull/Push code using SSH Key without Permission denied

Hello guys, to be honest, I am struggling with the Bitbucket Pipeline

Below is my question with Bitbucket Pipeline

Scenario:

- I have 2 repos: Library and Package. Library contains the source code and the Package contains specific code that would be re-used in many projects.

- Bitbucket Pipeline is enable for both Library and Package repo.

- I write the code in Library repo, build, and push the final code to Package repo. Therefore, Library and Package repos need to communicate using Bitbucket Pipeline.

Question:

- How can I use SSH Key in Bitbucket Pipeline to pull/push code from Library repo to Package repo without the permission denied?

- According to this link: the third comment from Maze Hawks, adding the SSH Key to Personal Setting allow to do it, but do we have any alternative ways so we don't have to add the SSH Key to Personal Setting?

If you have any ideas, please feel free to give the answers or comments. I am really appreciated.

1 answer

1 accepted

0 votes
Answer accepted

Hi @Luong Truong and welcome to the community!


- How can I use SSH Key in Bitbucket Pipeline to pull/push code from Library repo to Package repo without the permission denied?

If you want to use SSH, you can generate an SSH key pair from Repository settings > SSH keys in the Library repo, then, copy the public key.

Afterwards, go to your Personal settings > SSH keys and add the public key there.

If you have at least write access to Package repo, you'll be able to push this way from Pipelines of the Library repo.

- According to this link: the third comment from Maze Hawks, adding the SSH Key to Personal Setting allow to do it, but do we have any alternative ways so we don't have to add the SSH Key to Personal Setting?

Another way is to use HTTPS. You can generate an app password for your account that has at least write access to repositories:

Then to go Library Repository settings > Repository variables

Create two variables, named e.g. BitbucketUsername and BitbucketPassword (please make sure that BitbucketPassword is created as a secured variable, so no one else can see it)

Afterwards, you can use an HTTPS URL like the following to push:

https://$BitbucketUsername:$BitbucketPassword@bitbucket.org/<workspace-id>/<repo-slug>.git

There is another option, which is to use OAuth for authentication. This is explained in detail here:

Please note that the example there assumes that you are pushing back to the same repo where Pipelines runs.

Since you want to push to a different repo, you can change the variable ${BITBUCKET_REPO_SLUG} in the URL with the repo slug of the repo you are pushing to.

Does any of these options work for you?

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Hello @Theodora Boudale , thank you for your super clear answer. I am really appreciated.

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

104 views 1 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you