如何将 Jenkins Git 插件从使用 GIT_ASKPASS 更改为 .gitcredentials

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41466182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:44:08  来源:igfitidea点击:

How do I change Jenkins Git plugin from using GIT_ASKPASS to .gitcredentials

gitjenkins

提问by shaneoh

How do I change Jenkins Git plugin from using GIT_ASKPASS to .gitcredentials

如何将 Jenkins Git 插件从使用 GIT_ASKPASS 更改为 .gitcredentials

I've posted this question already:

我已经发布了这个问题:

Jenkins cannot read Github password since upgrading to Git client plugin 2.1.0

Jenkins 无法读取 Github 密码,因为升级到 Git 客户端插件 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.

简而言之,我已经克隆了 Jenkins 1.650 的生产实例,并将克隆的实例升级到了 Windows 2012 上的 2.25。

As part of this the Git Client plugin was upgraded from 1.19.6 to 2.1.0 and now it cannot authenticate.

作为其中的一部分,Git 客户端插件从 1.19.6 升级到 2.1.0,现在无法进行身份验证。

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 credentialsand on the cloned instance using GIT_ASKPASS to set credentials.

我现在注意到,我能看到的一个区别是,在作业输出中,在它工作的实例上有一条消息using .gitcredentials to set credentials,在克隆的实例上using 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.access0(CliGitAPIImpl.java:64)
08:18:41    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:315)
08:18:41    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.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

回答by shaneoh

This has been answered by a serverfault user:

这已由 serverfault 用户回答:

https://serverfault.com/questions/823152/how-do-i-change-jenkins-git-plugin-from-using-git-askpass-to-gitcredentials

https://serverfault.com/questions/823152/how-do-i-change-jenkins-git-plugin-from-using-git-askpass-to-gitcredentials

However in short there are known bugs with Jenkins 2+ in a Windows environment with reading passwords which contains a character which requires Windows escaping in the command prompt.

然而,简而言之,在 Windows 环境中,Jenkins 2+ 存在已知错误,读取密码包含一个需要 Windows 在命令提示符中转义的字符。

I changed the password for the Github account and this resolved the authentication issue.

我更改了 Github 帐户的密码,这解决了身份验证问题。