Search code examples
gitjenkinsremote-serverssh-keys

Can't connect jenkins to a remote git repository


I am trying to connect my jenkins to a remote git repo such as aa-bb-server

In the credentials configuration, I put the user name and the private key, this is what I get:

Failed to connect to repository : Command "git ls-remote -h aa-bb-server HEAD" returned status code 128:
stderr: fatal: 'aa-bb-server' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Changing the Jenkins user to root didn't work.

Locally I can ssh to the repo, clone, etc.


Solution

  • Hi please follow the below step if you installed jenkins in your server please initialize the git empty repository --> git init

    Then go to github --> click on profile dropdown --> settings --> devloper settings --> personal access token --> generate new token --> select all scopes --> copy the token

    Then go to Jenkins --> manage Jenkins --> github settings --> add user --> Select secret text ** --> **paste the token

    And test your git hub access after that go to project and add your repository URL (which is ends with .git)