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

Bamboo and git keys issue

renatoliveira April 24, 2015

I'm getting this error when trying to run a plan that retrieves the code/metadata from a Salesforce instance to a repository on Bitbucket.

Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I know that to push changes to a remote repository I need some kind of authentication, right. However, I don't know exactly where and how to set this up on Bamboo. My company is not using Stash or JIRA, just Bitbucket and Bamboo.

I have tried generating a key pair with puttygen and putting the public on Bitbucket, and the private key in the "Shared Credentials" section on Bamboo settings, and it doesn't work.

I have also tried to log into the Bamboo server with the pair provided by Amazon, and generating a pair from inside, using ssh-keygen. It didn't work either.

Where can I specify the key that Bamboo should use with this repo when pushing files? 

2 answers

1 accepted

1 vote
Answer accepted
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 24, 2015

Hello Renato,

Thank you for your question.

Please, create a Script task with the following example:

# create file
echo "hello, world" > greeting.txt
 
# add file
git add greeting.txt
 
# commit
git commit -m "add greeting"
 
# set url to push
# [username], i.e.: renato
# [password], i.e.: mypassABC
# [account-name], account name where the repository is hosted under
# [repo-slug], given name to the repository
git remote set-url --push origin https://[username]:[password]@bitbucket.org/[account-name]/[repo-slug].git
 
# push to Bitbucket repository
git push origin master
 
# remove origin
git remote remove origin

The above will let you push files to your repository. Please, notice in the example above it has been used HTTPS protocol instead of SSH. The reason for that is that Bamboo will expect you to type in the password for your SSH key while running the build.

Alternatively, you could create a passphraseless SSH key and replace the origin above to use this key.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

0 votes
Sebastian Wolf April 27, 2015

Hi Rafael and Renato,

We've ended up solving this problem by changing the dependency URL from SSH to HTTPS, and then specifying the user/pass in the URL using the "//[user]:[pass]@domain.com/team/repo.git" format.

We created a new read-only user with restricted permissions, and used their credentials for this. This has made the build succeed without any further Bamboo-specific configuration needed.

It's not the clean solution we were hoping for, but until Bamboo has support for specifying SSH config in non-checkout tasks, it'll have to do smile

Sebastian

PS. I've removed my previous answer because it was a horrible hack.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events