Jenkins - using GIT_ASKPASS to set credentials

2020-05-31 05:19发布

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?

标签: jenkins
4条回答
啃猪蹄的小仙女
2楼-- · 2020-05-31 05:44

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

查看更多
家丑人穷心不美
3楼-- · 2020-05-31 05:51

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.

查看更多
beautiful°
4楼-- · 2020-05-31 05:55

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.

查看更多
beautiful°
5楼-- · 2020-05-31 05:58

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.

查看更多
登录 后发表回答