4

Using jenkins to pull from bitbucket repository, I got this error:

[email protected]:source/source.git +refs/heads/:refs/remotes/origin/" returned status code 128: stdout: stderr: repository access denied. deployment key is not associated with the requested repository. fatal: Could not read from remote repository.

I have added ssh keys in the bitbucket repo, I have run ssh -v [email protected] and this is the output:

authenticated via a deploy key.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

This deploy key has read access to the following repositories:

source/source: root.staging_quc -- root@QUICKRESPONSE debug1: channel 0: free: client-session, nchannels 1 Connection to bitbucket.org closed. Transferred: sent 2968, received 1872 bytes, in 0.0 seconds Bytes per second: sent 82471.7, received 52017.2 debug1: Exit status 0

I don't really know what to do, hope you guys have any clue on this one I will update this question

2 Answers 2

1

First make sure that you added the public key to the right repo with the right permission, usually I add it to 'Access keys' so the user has read only permission, then to make sure that is working add the private key to you system so you can use it with using git:

ssh-add private-key
git clone <your git repo>

If it's working, add those credential to you jenkins and use them later

1
  • as you can see above I have add the public key to 'Access Key' and the deployment key has read access to the repo, but still I got the same error
    – spacetrack
    Aug 29, 2017 at 6:29
1

Hello guys I have found the solution, So I create ssh keys from my Jenkins Server, and then called the private key from my code, this is how it looks like on my project structure:

root@staging:~/project# tree
.
├── deployment.yaml
├── server
│   └── host
└── the_private_key

1 directory, 3 files

and my deployment.yaml:

---
- hosts: staging
  become_user: sudo
  tasks:
  - name: populate my project
    git: [email protected]:source/source.git
         version=master
         dest=/var/www/test/
         key_file=the_private_key
         accept_hostkey=yes

And then I copied Jenkins Server public key to Target Server, then everything worked well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.