GIT clone could not read from remote repository error in Bitbucket pipeline on self-hosted Runner

ForeverBaffled December 12, 2022

Hi,

I have a pipeline returning the following error. The pipeline runs on a self-hosted runner (Docker container) on Redhat instance.

 

[RuntimeException]
Failed to execute git clone --mirror -- 'git@bitbucket.org:company_work/repo_name.git' '/root/.composer/cache/vcs/git-bitbucket.org-company-work-repo-name.git/'
Cloning into bare repository '/root/.composer/cache/vcs/git-bitbucket.org-company-work-repo-name.git'...
ssh: connect to host bitbucket.org port 22: Cannot assign requested address
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

I have configured SSH keys as described in this thread

Also, is there a way to output more detailed logging when a pipeline runs? Is there any way to tell which container the pipeline is being executed? 

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 13, 2022

Hi @ForeverBaffled and welcome to the community.

If the server you are using is behind a firewall, please make sure to whitelist the following IP ranges:

I've seen this error occur mainly because of firewall rules blocking the connections to bitbucket.org

is there a way to output more detailed logging when a pipeline runs?

What kind of additional logging are you looking for? If you would like verbose output from the clone command, you can add the following arguments in the clone command in your yml file:

GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone <repo URlL>

Is there any way to tell which container the pipeline is being executed?

For every step of your build, a separate Docker container starts based on the image you have defined in your bitbucket-pipelines.yml file. If you haven't defined an image in the yml file, then the DockerHub image atlassian/default-image:latest will be used by default. While the step is running, you can run docker ps and if the step's build container has started, you should see it listed and identify it by the image name (if no other containers based on this image are running). Please keep in mind that each step's build container gets destroyed once the step finishes.

Kind regards,
Theodora

ForeverBaffled December 13, 2022

Thanks for the info @Theodora Boudale . After adding the arguments to the git clone command, I'm seeing the following after generating a key and adding my public key to Bitbucket > Repo > Security > Access Keys. Is this still a firewall on our side? 

OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019
debug1: Reading configuration data /root/.ssh/config
debug1: /root/.ssh/config line 1: Applying options for bitbucket.org
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "bitbucket.org" port 22
debug2: ssh_connect_direct
debug1: Connecting to bitbucket.org [104.192.141.1] port 22.
debug1: connect to address 104.192.141.1 port 22: Connection refused
debug1: Connecting to bitbucket.org [2406:da00:ff00::22c5:2ef4] port 22.

Also, we have other pipelines successfully completing on these self-hosted runners (containers). The difference here is that the pipeline clones another repo. 

I should add that if I git clone using https and use a personal app password, the cloning is successful.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 14, 2022

Hi @ForeverBaffled,

Thank you for the info.

The following error points to a network-related issue:

debug1: connect to address 104.192.141.1 port 22: Connection refused

The client hasn't reached the point where it offers the private SSH key for authentication, the operation fails before that, while it tries to establish a connection to Bitbucket. After that line, I also see an attempt to connect via IPv6:

debug1: Connecting to bitbucket.org [2406:da00:ff00::22c5:2ef4] port 22.

Is there a 'Connection refused' error after that as well?

If using HTTPS is successful, then the issue may be specific to SSH. Perhaps port 22 is blocked? HTTPS and SSH use different ports, and when you run a pipelines runner build the clone that happens in 'Build Setup' uses HTTPS as well.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events