Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Composer install private repositories

krajcik
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 5, 2018

Hi,

 

I have project which require in composer my private package from bitbucket.

 

I have following pipeline in my bitbucket-pipeline yml file

 

pipelines:
branches:
master:
- step:
script:
- apt-get -y install openssh-server
- echo $PRIVATE_KEY > ~/.ssh/id_rsa.tmp
- base64 -d ~/.ssh/id_rsa.tmp > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- base64 ~/.ssh/id_rsa
- chmod 600 ~/.ssh/config
- chmod 700 ~/.ssh
- apt-get install git -y
- apt-get install -y php7.1-cgi
- apt-get install -y php7.1-json
- composer install
- sh bin/cli/test.sh

 

But in time of installation my private repository by composer I get following error:

 

 

 Failed to execute git clone --no-checkout 'git@bitbucket.org:krajcik/cms-banner-module.git'
'/opt/atlassian/pipelines/agent/build/vendor/krajcik/cms-banner-module' && cd '/opt/atlassian/pipelines/agent/build/vendor/krajcik/cms-banner-module' && git remote add composer 'git@bitbucket.org:krajcik/cms-banner-module.git' && git fetch composer
Cloning into '/opt/atlassian/pipelines/agent/build/vendor/krajcik/cms-banner-module'... Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.  

 

In my environment variables in butbucket I have variable PRIVATE_KEY with ssh key in base64. Key was generated without passphrase.

 

When I execute:

composer install

 on my computer with same ssh key then everything execute successfully but in bitbucket throw error.

 

Can you help we with my issue?

 

Thank you very much :-)

1 answer

0 votes
Linette
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 7, 2018

You could add your SSH key to pipelines specifically following this guide: https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html?_ga=2.131578383.1856844316.1538948135-298513200.1517436601

 

The section at the bottom about multiple keys looks quite like what you are already doing, and so, if you expand that section, check through that you've done each step, especially step 5...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events