jenkins not able to connect to a repository

I have just installed jenkins on an amazon EC2 box and i am trying to setup a job. I have installed git plugin and then i gave the url of my repo in the job’s git repo field and i get the following error.

Failed to connect to repository : Command "git ls-remote -h HEAD" returned status code 128:
stderr: fatal: Authentication failed

The repository is a private one hosted at bitbucket and i know i should give user name and password somewhere on this git plugin but i don’t see where. Attached is the screenshot as well for the reference.

enter image description here

  • getting NuGet to work both with whole solution and individual projects included in it
  • Why the GITHUB Plugin Jenkins doesn't show up in Jenkins configuration?
  • How to start jenkins on different port rather than 8080 using command prompt in Windows?
  • Jenkins, git, submodules with custom URL (SSH)
  • Declarative Jenkins pipeline with Nightly deploy for master branch
  • Upstream dependency aware incremental build in Jenkins
  • How do I push changes from one branch to another branch after a successful Jenkins build?
  • Jenkins Host key verification failed
  • 3 Solutions collect form web for “jenkins not able to connect to a repository”

    I found the problem. I had to actually add my ssh keys to the bitbucket server. Basically these steps

    1. generate ssh keys
    2. go to bitbucket repo settings
    3. click on deployment keys
    4. add the pub key

    and vola you are done.

    Just for the records (if somebody’s looking around with a similar issue – like me 🙂

    I have had a comparable problem – like shown in the above screenshot I was entering a “connection string” to the GIT in the format: https://<user>:<password>@<URL> and receiving a “failed to connect” where the connection URL was reduced to https://<user>@<URL> – where of course was clear why it failed: The password wasn’t submitted !?

    After digging around I found this cause. On the environment where the problem occurred I had a newer Jenkins version (which is no issue:). But that newer Jenkins had the latest plugins ‘GIT-client’ version 1.4.4 and ‘GIT’ version 2.0 installed.

    This obviously is causing a problem. Reverting to versions 1.0.7 respectively 1.5.0 (and a Jenkins restart) solved it. Keeping one of both plugins on the newer version and only downgrading the other produced another symptom: The GIT was no longer available for configuration. So there’s a dependency between both plugins.

    The “million-dollar-question” is: Is this a bug in those plugins? Or or do they simply need to be handled/configured differently. I didn’t find any hint on this so far ..

    Some more light on this (like as well in my reply to Jenkins: Failed to connect to repository )

    In short:
    IMHO the credentials-helper plugin is the main cause of all the trouble and still is buggy in version 1.9.4 !

    How ever the following workaround does the trick (even with the newer/st GIT-Client/GIT plugins)

    The Jenkins service process needs to be able to process the webserver certificate. Just that the Jenkins service doesn’t use the global ‘.gitconfig’ but needs to be explicitly pointed to a keystore holding this certificate. Then for the service startup use the additional parameter

    ‘”keystore” ‘

    If you then put the logon credentials into a ‘.netrc’ you don’t need to specify any credentials in the Jenkins any more …

    But using the credential-helper plugin … no luck 🙁
    If someone should know, please reply

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