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

Not mirroring Bitbucket repo to GitHub

Tomík June 9, 2023

This is my code in pipeline:

- step: name: Sync GitHub Mirror

  image: alpine/git:1.0.26

  services:

  - docker

  script:

  - git remote add github "git@github.com:[yourname]/[your repo].git"

  - git checkout $BITBUCKET_BRANCH

  - git pull

  - git push github $BITBUCKET_BRANCH

 

 

But pipeline failed:

+ git push github $BITBUCKET_BRANCH

Warning: Permanently added the ECDSA host key for IP address '140.82.114.4' to the list of known hosts.

remote: fatal: did not receive expected object 205375ad4df64d611dcd802c66cad202f89b5370

error: remote unpack failed: index-pack failed

And aslo i dont fetch fingerprint to host addres (github.com) in ssh known hosts in setting project:

Bad request
The request body contains invalid properties

Where is problem and how is solutions. Thanks.

 

 

 

 

 

2 answers

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 12, 2023

Hi @Tomík and welcome to the community!

Just to give you some context, Pipelines builds run in Docker containers. For every step of your build, a Docker container starts (the build container) using the image you have specified in your bitbucket-pipelines.yml file. If you use a service for a step, then a second Docker container will start for the service which will share a network adapter with your build container. The repo is cloned in the build container, and then the commands of the step's script are executed. When the step finishes these Docker containers get destroyed.

By default, the git clone operation will use a depth of 50, so only the last 50 commits will be cloned. If the GitHub repo you want to push to is empty, then the error shows because it is not possible to push from a shallow clone to a new, empty repo.

You can use the following on your step so that all the commits of the branch will get cloned (this is the documentation on the clone depth):

clone:
depth: full

After you run the first pipeline, you can remove this.


You could also push first the main branch of your repo to the GitHub repo from a local clone, and then your pipeline should work without the need to edit the bitbucket-pipelines.yml file to add and remove the depth option.


The command git checkout $BITBUCKET_BRANCH in your script is not necessary, as when you run a pipeline on a branch, this specific branch will already be checked out.


Bitbucket Pipelines automatically adds the fingerprint for the Bitbucket and GitHub sites to all pipelines (but doesn't display that in the UI), so there is no need to add the fingerprint.

Please feel free to reach out if you have any questions.

Kind regards,
Theodora

0 votes
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 12, 2023

In the URL you are using, you need to enter your GitHub username and repo name, so that the URL becomes a working absolute URL without placeholders:

git@github.com:[yourname]/[your repo].git

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events