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

Cannot push to codecommit using bitbucket pipelines

Vimal krishnamoorthy October 24, 2018

Hi All,

 

I am trying to push the repository to codecommit through bitbucket pipeline. It was working fine . 

Now, I am facing an error. the error looks like.

 

remote: processing ... remote: Unknown commit d7e9a3fbcef21e0ac40ba142f2f528cd0d3db1b1error: unpack failed: Unknown commit d7e9a3fbcef21e0ac40ba142f2f528cd0d3db1b1To ssh://git-codecommit.us-west-2.amazonaws.com/<repodetails> [remote rejected] Development -> Development (unpacker error)error: failed to push some refs to 'ssh://git-codecommit.us-west-2.amazonaws.com/<repodetails>'

 

this prevents from pushing to remote AWS codecommit.

 

Any idea how to solve this. I did check the mentioned commit and its assigned perfectly fine with the author details.

 

Vimal

2 answers

1 accepted

4 votes
Answer accepted
Graham Gatus
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 28, 2018

@Vimal krishnamoorthy do you mind sharing a snippet from you bitbucket-pipelines.yml file? I haven't used CodeCommit before, however something to consider is that in pipelines, we perform a shallow clone of your repository (to a depth of 50, see the log output from Build Setup). 

Its possible that you are now trying to push to CodeCommit without having the full commit history. 

Are you able to push the same commit from your local machine?  I would also suggest trying to test locally by cloning your repository with a depth of 50 (git clone --depth 50 <your repo>), then try to push to CodeCommit, and see if depth causes it to break.

Vimal krishnamoorthy October 30, 2018

Yes , You where right. We moved to bitbucket from github recently and this was the reason for not having a complete commit history. And CodeCommit will throw an error in such cases. 

I started everything fresh from scratch in bitbucket by creating a new fresh repository and IT WORKED. It was better then wasting time trouble shooting the issue.

 

THANKS FOR THE HELP. BTW THIS WAS MY yml file.

 

- step: name: Pushing Repository to AWS codecommit

deployment: staging

script:

- echo $CodeCommitKey > ~/.ssh/id_rsa.tmp

- base64 -d ~/.ssh/id_rsa.tmp > ~/.ssh/id_rsa

- chmod 400 ~/.ssh/id_rsa

- echo $CodeCommitConfig > ~/.ssh/config.tmp

- base64 -d ~/.ssh/config.tmp > ~/.ssh/config

- set +e

- ssh -o StrictHostKeyChecking=no $CodeCommitHost

- set -e

- git remote add application ssh://$CodeCommitRepo

- git push application $BITBUCKET_BRANCH

Graham Gatus
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 31, 2018

@Vimal krishnamoorthy if you don't mind me asking, what method did you use to migrate over from github? I'm curious to find out how this could have caused issues in this case?

James Hulse February 19, 2019

@Graham Gatus for anyone else coming across this issue, I ran into the same thing when trying to push directly from a Bitbucket pipeline to a brand new CodeCommit repository.

The issue *does* seem to be the lack of history. To solve the issue I first pushed from my local machine, then subsequent pushes from the Bitbucket pipeline worked. 

Like # people like this
Brunux February 21, 2019

I can confirm the issue was `--depth 50` no matter if you already made a commit before, I fix it basically squashing all to one commit

Like # people like this
richard June 10, 2019

I fix it basically squashing all to one commit

- How to do it? Got into the same problem, and it seems I don't have any idea how to squash it to one commit :(

havoknz June 10, 2019

Richard, if you have a long git history then squashing isn't necessarily a good idea.


Solution 1 (recommended): Push your repository from your local machine to CodeCommit manually one time. This will give CodeCommit the full history and ensure that pipelines can push future commits.


Solution 2 (not recommended): Delete your .git folder and force push to your bitbucket repository. This will mean your history is < 50 commits which means the shallow pull that pipelines does will still work for updating CodeCommit. This will squash your history to one commit.

Like # people like this
0 votes
Abhishek Tiwari June 30, 2019

Hi @Vimal krishnamoorthy ,

Use ssh keys you'll need to setup both the sender (pipelines) and the receiver (aws codecommit)

To set up ssh keys for use in pipelines you can consult our documentation here https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html

To set up ssh keys for use in aws codecommit you can consult the documentation here https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html

If you have any other questions let me know.

Cheers,

Abhishek

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events