【问题标题】:Jenkins : use Execute Windows Batch command to run GIT commands : change userJenkins:使用 Execute Windows Batch 命令运行 GIT 命令:更改用户
【发布时间】:2017-05-25 05:02:18
【问题描述】:

我在这方面花了很多时间。这不是 the cygwin post that is first on google search 的副本。

普通 GIT 存储库使用凭据 - 我在 Jenkins 上有很多项目,使用 GIT,它们都运行良好。这些 repo 获取存储库 URL 和凭据和分支,并且显然使用 GIT 进行操作。

现在,我需要执行一个 GIT 命令。这是一个简单的git tfs pullgit push.

当我在控制台中运行这些命令时,它工作正常。当我将它放入批处理文件并自己执行时,它运行良好。当我在“执行 Windows 批处理命令”中运行命令时,它会挂起并且不执行。

我怀疑它需要凭据。我不知道如何发送批处理命令的凭据。

have runset命令,并且可以确认在Jenkins执行期间运行的用户不是我在命令提示符下运行时的同一用户。

如何设置用户运行这个批处理命令?

【问题讨论】:

  • 您使用的是 https 网址吗?还是 ssh 网址?
  • 我正在使用 https 网址

标签: git authentication jenkins execute


【解决方案1】:

默认情况下,Git for Windows 将通过Git-Credential-Manager-for-WindowsCredential Manager of Windows 用作凭据管理器。

检查输出

cd /path/to/repo
git config credential.helper

这是使用为给定用户缓存的凭据。一种替代方法是将这些凭据设置在一个简单的文本文件中(用于测试):请参阅“Git Tools - Credential Storage”。

cd /path/to/repo
git config credential.helper store --file /path/to/repo/.git/.my-credentials

这样,该存储库中的任何用户都将使用正确的凭据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 2020-04-19
    • 2018-02-22
    • 1970-01-01
    相关资源
    最近更新 更多