34

I've set up some credentials in Jenkins for bitbucket and double-checked the Credentials settings (e.g. logging in manually) however when I try it in Jenkins it just spins forever giving this output:

> git config remote.origin.url <bitbucket url> # timeout=10
Fetching upstream changes from <bitbucket url>
> git --version # timeout=10
using GIT_ASKPASS to set credentials <bitbucket account email> Bitbucket
> git fetch --tags --progress <bitbucket url> +refs/heads/*:refs/remotes/origin/*
> git fetch --tags --progress <bitbucket url> +refs/heads/*:refs/remotes/origin/*

Note that the URL is fine when public. But when set to Private it simply fails with no output.

Is there anyway to debug this in a bit more detail?

Snowcrash
  • 80,579
  • 89
  • 266
  • 376

7 Answers7

32

I had a similar issue, with Jenkins on a Windows server. I installed git with credentials manager and whenever it tried to checkout a private repository, it would wait for me to input credentials manually in the server. Disabling the git credential manager fixed it for me.

I already had an option to input credentials in the git plugin so didn't need a separate credentials manager.

pratikpncl
  • 508
  • 5
  • 10
8

This is on MacOSX. I changed the Jenkins setting on Git path to /usr/local/git as well as unset the credential.helper using git config, both don't work.

Finally, the problem was resolved by creating a default keychain file for jenkins in ~jenkins/Library/Keychains folder. Herewith is the steps...

  • sudo su jenkins
  • mkdir ~jenkins/Library/Keychains
  • cd ~jenkins/Library/Keychains
  • security create-keychain -p [pwd] ./Login.keychain
  • security login-keychain -d user -s ./Login.keychain
  • check default keychain setup properly
security default-keychain
  • git fetch --tags --progress https://github.com/....git +refs/heads/:refs/remotes/origin/

After that, the github userid/password is stored in jenkins default keychain and it will be used on jenkins build.

kchoi
  • 109
  • 1
  • 4
3

I had this problem on OSX. My issue was that Jenkins was using the wrong Git executable (I verified this by disabling the checkout step and adding which git before anything else).

I ran which git in terminal and copy-pasted the path into Manage Jenkins -> Global Tool Configuration -> Git -> Path to Git executable. It worked after that.

akiraspeirs
  • 2,127
  • 2
  • 21
  • 29
3

I had a similar issue, with Jenkins on a Windows server. I installed git with credentials manager and whenever it tried to checkout a private repository, it would wait for me to input credentials manually in the server. Disabling the git credential manager fixed it for me.

Actually, that should now (Q1 2021) work without having to disable the credential helper with Git 2.30.

"git credential(man)' didn't honor the core.askPass configuration variable (among other things), which has been corrected with Git 2.30 (Q1 2021).

See commit 567ad2c (15 Oct 2020) by Thomas Koutcher (koutcher).
(Merged by Junio C Hamano -- gitster -- in commit e0f6ad2, 02 Nov 2020)

credential: load default config

Signed-off-by: Thomas Koutcher [jk: added test]
Signed-off-by: Jeff King peff@peff.net
Signed-off-by: Junio C Hamano gitster@pobox.com

Make git credential fill(man) honour the core.askPass variable.


As noted by kymikoloco in the comments, upgrading to the latest (Nov. 2021) Git for Windows 2.34 seems enough to solve the issue.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I had such problem with Jenkins on Windows 10. It always showed failure with permission denied error, code 128 returned by git.exe after ...GIT_ASKPASS for credentials step. Changing credential.helper and env.variable GIT_ASKPASS did not help me at all, the same behaviour.

Then i checked up which git.exe in cmd where git and was suprised, it was SmartGit's internal one.

I changed it to JGit in Jenkins global settings and it works now.

https://i.stack.imgur.com/IBfIi.png

aka Pipo
  • 46
  • 4
-1

Its works for me!

  1. Goto Dashboard --> configuration
  2. Scroll down to find Git plugin
  • input Global Config user.name Value: ex: jenkins
  • input Global Config user.email Value ex: youremail@gmail.com
-4

you need to generate an SSH key from Git and add it to Bitbucket

Jay
  • 1