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:
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.