Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins - using GIT_ASKPASS to set credentials

Tags:

jenkins

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?

like image 620
Snowcrash Avatar asked Mar 06 '17 13:03

Snowcrash


People also ask

How do I add repository credentials in Jenkins?

For that purpose, we need to click on the Manage Jenkins option. Step 2: Then, a new tab will open. There we need to click on the Manage Plugin option to add the Credential option there. Step 3: Then we need to click on the Available Tab & we should search for 'Credential' in the search bar provided there.

What is Git_askpass?

Git Askpass for Windows (Askpass) provides secure Git credential storage for Windows. Askpass provides multi-factor authentication support for Azure DevOps, Team Foundation Server, and GitHub.

How do I use git credentials in Jenkins pipeline?

To understand how to configure credentials in a Jenkins environment: Using Credentials. gitToolName. Name of the git installation in the machine running the Jenkins instance (Check Global Tool Configuration section in Jenkins UI)

How do I update global credentials in Jenkins?

From the Jenkins home page (i.e. the Dashboard of the Jenkins classic UI), click Manage Jenkins > Manage Credentials. Under Stores scoped to Jenkins on the right, click on Jenkins. Under System, click the Global credentials (unrestricted) link to access this default domain. Click Add Credentials on the left.


2 Answers

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.

like image 156
pratikpncl Avatar answered Sep 28 '22 01:09

pratikpncl


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.

like image 21
kchoi Avatar answered Sep 28 '22 00:09

kchoi