AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 823152
Accepted
shaneoh
shaneoh
Asked: 2016-12-30 00:28:08 +0800 CST2016-12-30 00:28:08 +0800 CST 2016-12-30 00:28:08 +0800 CST

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

  • 772

我已经发布了这个问题:

Jenkins 升级到 Git 客户端插件 2.1.0 后无法读取 Github 密码

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

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

如果我再次降级此插件,我的作业可以完美运行,但是当使用升级的插件运行它们时,作业会失败。

我现在注意到我可以看到的一个区别是,在作业输出中,在它工作的实例上有一条消息using .gitcredentials to set credentials,而在克隆的实例上using GIT_ASKPASS to set credentials。

我怀疑这是问题所在,或者至少是相关的,但我找不到改变它的方法。以下失败作业的完整输出:

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

编辑

根据鲍勃的建议,我已经成功运行了这些命令。

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/*

但是,运行我的工作时的输出完全相同。仍在使用 GIT_ASKPASS。必须有一种方法可以恢复为 .gitcredentials。

git jenkins windows-server-2012
  • 4 4 个回答
  • 29365 Views

4 个回答

  • Voted
  1. Best Answer
    Mark Waite
    2017-01-07T01:59:55+08:002017-01-07T01:59:55+08:00

    您无法将 Jenkins git 客户端插件从使用 ASKPASS 更改为使用 .gitcredentials。该插件没有可选择的密码提示方法。

    它在 2.0 之前的版本中使用 .gitcredentials,并在 2.0 及更高版本中切换到 ASKPASS。进行了该更改,以便可以在 git 客户端插件 2.0 中添加子模块身份验证。

    有一些开放的错误报告描述了基于 Windows 的用户名/密码设置不再适用于基于 https 的对 git 存储库的访问的情况。其中一些场景包括:

    • 密码包含需要 Windows 转义的字符,但插件无法正确转义密码(JENKINS-40166、JENKINS-38194 和 JENKINS-38179)
    • TFS 2015 JENKINS-38138 的未知故障模式

    在修复这些开放错误之前的一些临时替代方案包括:

    • 保持当前版本(git 客户端插件 1.19.6 和 git 插件 2.x)
    • 下载并安装 git 客户端插件 1.21.0 和 git 插件 2.6.1,以便您可以在更改凭据之前继续使用 git 客户端插件。您需要从 URL updates.jenkins-ci.org/download/plugins/git 和 updates.jenkins-ca.org/download/plugins/git-client 下载,然后使用 Jenkins 插件管理器“高级”选项卡上传那些较新(但不是最新)版本的 git 客户端插件和 git 插件
    • 协助评估待处理的 git 客户端插件拉取请求,该请求会调整插件中密码的 Windows 转义。拉取请求是 github 上的 PR231
    • 2
  2. bobs
    2017-01-05T10:33:59+08:002017-01-05T10:33:59+08:00

    在 Git 客户端插件2.1.0 -> 2.2.0和 Git 插件2.5.2 -> 3.0.1之后,我也发生了同样的事情。在恢复那些没有修复它之后,我从这个文件中删除了所有 [credential] 条目:(c:\users\user\.gitconfig 即全局:)git config --global --list然后重置(添加?)这个

    git config --global credential.helper manager
    

    然后做了一个示例 git fetch,现在弹出窗口输入 ID/PW,它与管理器缓存它。随后的调用工作。

    • 1
  3. bobs
    2017-01-06T04:19:30+08:002017-01-06T04:19:30+08:00

    我认为凭据被其中一个插件更新弄乱了,所以我基本上清除了所有以前的设置并重置它。这就是我所做的,一个命令一个命令:

    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/*
    

    在弹出的对话框中输入 ID/PW

    完毕。现在,当我运行任何 git 命令(包括使用此 ID 构建的詹金斯)时,它不再提示输入密码,就像我更新插件之前一样。

    • 0
  4. piglesias
    2017-06-30T00:12:20+08:002017-06-30T00:12:20+08:00

    这对我有用。

    似乎当您尝试连接到存储库时,它不使用提供的凭据,而是使用为提供的存储库 url 存储的 windowscredentials。

    因此,我完成这项工作的方式是:

    1. 使用相同的用户登录 de slave 服务器,使 jenkins 节点运行(在我的情况下是运行该服务的用户)

    2. 使用 git 客户端在任何你想要的地方创建一个 git 存储库并创建一个 git 克隆。将提示您输入凭据。放置正确的凭据并确保您将存储库中的文件放到所选位置。

    3. 通过控制面板\用户帐户\凭据管理器-> Windows 凭据检查存储的凭据。(一般来说应该是与您的 URL 相关的一个)

    4. 配置要从 GIT 下载的任务。放上网址,应该没有红色的警告信息。我已经测试过这项工作没有在詹金斯中提供凭据。

    5. 你完成了!

    • 0

相关问题

  • 如何使用 Gitosis 删除 Git 存储库

  • Git 和 Mercurial

  • 如何修复 git 中第一次提交的元信息?

  • 如何编辑 git 的历史记录以更正不正确的电子邮件地址/名称 [关闭]

  • git如何控制访问权限

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve