How do I change Jenkins Git plugin from using GIT_ASKPASS to .gitcredentials
Solution 1
You can't change the Jenkins git client plugin from using ASKPASS to using .gitcredentials. The plugin does not have selectable password prompting methods.
It used .gitcredentials in releases prior to 2.0, and switched to ASKPASS in releases 2.0 and later. That change was made so that submodule authentication could be added in git client plugin 2.0.
There are open bug reports which describe some scenarios where Windows based username / password setups no longer work with https based access to a git repository. Some of those scenarios include:
- Password contains a character which requires Windows escaping, but the plugin does not escape the password correctly (JENKINS-40166, JENKINS-38194, and JENKINS-38179)
- Unknown failure mode with TFS 2015 JENKINS-38138
Some temporary alternatives prior to the fixes for those open bugs include:
- Stay with your current versions (git client plugin 1.19.6 and git plugin 2.x)
- Download and install git client plugin 1.21.0 and git plugin 2.6.1 so that you can stay with git client plugin prior to the credentials change. You'd need to download from URL updates.jenkins-ci.org/download/plugins/git and updates.jenkins-ca.org/download/plugins/git-client , then use the Jenkins plugin manager "Advanced" tab to upload those newer (but not newest) versions of the git client plugin and git plugin
- Assist with evaluation of the pending git client plugin pull request which adjusts the Windows escaping of passwords in the plugin. The pull request is PR231 on github
Solution 2
Same thing happened to me after Git client plugin 2.1.0 -> 2.2.0 and Git plugin 2.5.2 -> 3.0.1. After reverting those didn't fix it, I deleted all the [credential] entries from this file: c:\users\user\.gitconfig
(i.e. the globals: git config --global --list
) and then reset (added?) this
git config --global credential.helper manager
and then did a sample git fetch, which now pops up window to enter the ID/PW, which caches it with the manager. Subsequent calls work.
Related videos on Youtube
shaneoh
Updated on September 18, 2022Comments
-
shaneoh over 1 year
I've posted this question already:
Jenkins cannot read Github password since upgrading to Git client plugin 2.1.0
In short I have cloned my production instance of Jenkins 1.650 and upgraded the cloned instance to 2.25 on Windows 2012.
As part of this the Git Client plugin was upgraded from 1.19.6 to 2.1.0 and now it cannot authenticate.
I have jobs which run perfectly if I downgrade this plugin again, but when running them using the upgraded plugin the jobs fail.
I have now noticed that the one difference I can see is that in the job output, on the instance where it works there is a message
using .gitcredentials to set credentials
and on the cloned instanceusing GIT_ASKPASS to set credentials
.I suspect this is the issue or is at least related but I cannot find a way to change this. Full output of failing jobs below:
08:18:40 Cloning the remote Git repository 08:18:40 Cloning repository https://github.com/mycompany/myrepo.git 08:18:40 > C:\Program Files\Git\cmd\git.exe init C:\Program Files (x86)\Jenkins\workspace\project # timeout=10 08:18:40 Fetching upstream changes from https://github.com/mycompany/myrepo.git 08:18:40 > C:\Program Files\Git\cmd\git.exe --version # timeout=10 08:18:40 using GIT_ASKPASS to set credentials 08:18:40 > C:\Program Files\Git\cmd\git.exe fetch --tags --progress https://github.com/mycompany/myrepo.git +refs/heads/*:refs/remotes/origin/* 08:18:41 ERROR: Error cloning remote repo 'origin' 08:18:41 hudson.plugins.git.GitException: Command "C:\Program Files\Git\cmd\git.exe fetch --tags --progress https://github.com/mycompany/myrepo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: 08:18:41 stdout: 08:18:41 stderr: '*dds23' is not recognized as an internal or external command, 08:18:41 operable program or batch file. 08:18:41 error: unable to read askpass response from 'C:\Windows\TEMP\pass6274847349411211542.bat' 08:18:41 bash: /dev/tty: No such device or address 08:18:41 error: failed to execute prompt script (exit code 1) 08:18:41 fatal: could not read Password for 'https://[email protected]': No error 08:18:41 08:18:41 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745) 08:18:41 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1489) 08:18:41 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64) 08:18:41 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315) 08:18:41 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:512) 08:18:41 at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1054) 08:18:41 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094) 08:18:41 at hudson.scm.SCM.checkout(SCM.java:495) 08:18:41 at hudson.model.AbstractProject.checkout(AbstractProject.java:1278) 08:18:41 at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604) 08:18:41 at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) 08:18:41 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) 08:18:41 at hudson.model.Run.execute(Run.java:1720) 08:18:41 at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531) 08:18:41 at hudson.model.ResourceController.execute(ResourceController.java:98) 08:18:41 at hudson.model.Executor.run(Executor.java:401) 08:18:41 ERROR: null 08:18:41 Archiving artifacts 08:18:41 [htmlpublisher] Archiving HTML reports... 08:18:41 [htmlpublisher] Archiving at PROJECT level C:\Program Files (x86)\Jenkins\workspace\project\server.project\server.distribution\target\htmldocs\documentation to C:\Program Files (x86)\Jenkins\jobs\project\htmlreports\documentation 08:18:41 ERROR: Specified HTML directory 'C:\Program Files (x86)\Jenkins\workspace\project\server.project\server.distribution\target\htmldocs\documentation' does not exist. 08:18:41 [BFA] Scanning build for known causes... 08:18:41 [BFA] No failure causes found 08:18:41 [BFA] Done. 0s 08:18:41 Started calculate disk usage of build 08:18:41 Finished Calculation of disk usage of build in 0 seconds 08:18:41 Started calculate disk usage of workspace 08:18:41 Finished Calculation of disk usage of workspace in 0 seconds 08:18:42 Sending e-mails to: bob@yeah 08:18:43 Finished: FAILURE
EDIT
As per the suggestions from bobs, I have successfully run these commands.
del c:\users\user-name\.gitconfig git config --global credential.helper manager git fetch --tags --progress https://stash/myproj/proj.git +refs/heads/*:refs/remotes/origin/*
However output when running my job was exactly the same. Still using GIT_ASKPASS. There must be a way to revert to .gitcredentials.
-
shaneoh over 7 yearsWould you mid explaining how to do this exactly? It's a little unclear from your comment.
-
shaneoh over 7 yearsQuestion has been edited
-
shaneoh over 7 yearsI changed my password so that it doesn't have these characters and now the authentication is fine, so thanks a lot for this.