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

Git clone private repository in a Pipeline job ?

Jérôme TAMARELLE October 18, 2016

To run a build of my application in Bitbucket Pipeline, I need to download its dependencies first.

I'm using composer do manager dependencies, but it would be the same with npm.

{
	"repositories": [
		{
			"type": "vcs",
			"url": "git@bitbucket.org:mycompany/myrepository.git"
		}
    ],
	"require": {
		"mycompany/myrepository": "dev-master",
	}
}
image: phpunit/phpunit:5.5.0

pipelines:
  default:
    - step:
        script:
          - composer install
          - phpunit

Bitbucket Pipeline don't have access to clone the private Git repository.

[RuntimeException]                                                                                                                                                                                                                                                                                                                                                                                                                
  Failed to execute git clone --no-checkout 'git@bitbucket.org:mycompany/myrepository.git' '/opt/atlassian/pipelines/agent/build/vendor/mycompany/myrepository' && cd '/opt/atlassian/pipelines/agent/build/vendor/mycompany/myrepository' && git remote add composer 'git@bitbucket.org:mycompany/myrepository.git' && git fetch composer  
  Cloning into '/opt/atlassian/pipelines/agent/build/vendor/mycompany/myrepository'...                                                                                                                                                                                                                                                                                                                       
  error: cannot run ssh: No such file or directory                                                                                                                                                                                                                                                                                                                                                                                  
  fatal: unable to fork

 


2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 18, 2016

Hi Jérôme,

It's hard to tell from the error message exactly what the issue is, but in order to clone other private repositories you'll need to make sure the necessary tools are installed in the docker image that you're using (git, ssh) and you'll need to configure ssh. Here are some guides for configuring ssh:

https://answers.atlassian.com/questions/39429257

https://answers.atlassian.com/questions/39243415

cheers,
Steven

0 votes
shahafan September 17, 2018

just faced this issue so if anyone is having that issue the simple solution is to install ssh client on the pipeline image

 

script:
- apk add openssh-client
TAGS
AUG Leaders

Atlassian Community Events