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

pip install a private repo in Bitbucket Pipeline within Dockerfile

I have a private repo that is a dependency as a pip install. I have the proper ssh keys added to the repo I am running the pipeline on, but they are not working within the docker image. How do I get they keys in the docker container so the pip install won't fail?

I have added the following based off of other articles I have read, but once I get to ssh-add ~/.ssh/id_rsa, I get Error loading key "/root/.ssh/id_rsa": invalid format.



- step:
name: Build and Test
- export SSH_PRIVATE_KEY=`cat /opt/atlassian/pipelines/agent/data/id_rsa`
- docker build . --file Dockerfile --tag ${IMAGE_NAME}
- docker save ${IMAGE_NAME} --output "${IMAGE_NAME}.tar"
- docker
- docker
- "*.tar"




RUN mkdir ~/.ssh/
RUN echo "${SSH_PRIVATE_KEY}" > ~.ssh/id_rsa
RUN chmod 600 ~/.ssh/id_rsa
RUN touch ~/.ssh/known_hosts
RUN ssh-keyscan >> ~/.ssh/known_hosts
RUN eval $(ssh-agent -s)
RUN ssh-add ~/.ssh/id_rsa


1 answer

0 votes

Hi, @Chance Gehrke! Welcome to the community! 

Could you please try to use the following command to build the image?

- docker build --build-arg SSH_PRIVATE_KEY . --file Dockerfile --tag ${IMAGE_NAME}

I hope this helps, but do let me know if you have any questions. 

Kind regards,

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,470 views 3 10
Read article

Atlassian Community Events