Setting git private repository project on jenkins server

I am trying to set git private repo on jenkins server. I have installed git plugin and also github. when I set repo url in jenkins project ui the error is

Failed to connect to repository : Command "git -c core.askpass=true 
ls-remote -h HEAD" returned 
status code 128:
stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedl

What I have done up to now:

  • Using git subtree merging, while also merging in all branches of all merged subtrees
  • Using vim as git difftool
  • How to maintain code review history in Stash pull requests
  • Is it possible to have different .gitconfig files for different folders
  • git post-receive hook and multiple commits in one push
  • Move several commits from one branch to another?
    1. My server user and jenkin user( both are in same server) are different. Though it seems to me these are not related. jenkins user are given all credintial.

    2. In my server under var/lib/jenkins/.ssh(.ssh is created by me) I added ssh key . Public key is added to github repo.

    3. By swithcting user to jenkins i can clone the project by this ssh. So i think there is not any public key adding problem.

    I have googled the problem. there are many solutions. I tried most of them. But still no solution. Probably I am missing something.

    My repo url is something like this

  • On Windows git pull and clone for Google cloud repository pops credential manager dialog box
  • Vim: Warn if file is not tracked in Git
  • How to create a new git repository with a file that is already in a git repository, keeping the commits
  • Storing Jenkins configuration for multiple environments
  • What are the mechanics of git-revert command
  • Git stash pop- needs merge, unable to refresh index
  • 2 Solutions collect form web for “Setting git private repository project on jenkins server”

    If your HOME set in /var/lib/jenkins/ then i hope all the step you have been done successfully 🙂

    Then one thing may be happen for your case. Like when you switch the user by using:

    su jenkins 

    This command means that you switch the user but the home directory will be same as a root’s home!

    So you need to switch user by confirming the specific user home also switched. TO doing so, you need to follow:

    su -s /bin/bash jenkins

    Then you need to generate either the ssh public key once again or just update the known host. This will work.

    Related Link

    It depends on what HOME is set to when Jenkins is running: git will look for the ssh (public and private) keys under $HOME/.ssh.

    Simply add a build step with an echo $HOME, and make sure your .ssh is in that folder.

    Git Baby is a git and github fan, let's start git clone.