Jenkins:使用执行 Windows 批处理命令到 运行 GIT 命令:更改用户
Jenkins : use Execute Windows Batch command to run GIT commands : change user
我在这上面花了很多时间。这不是 the cygwin post that is first on google search.
的副本
正常 GIT Repo 使用凭据 - 我在 Jenkins 上有很多项目,使用 GIT,它们都工作正常。这些 repo 使用存储库 URL 和凭据和分支,显然使用 GIT 进行操作。
现在,我需要执行 GIT 命令。这是一个简单的 git tfs pull
和 git push.
当我在控制台中 运行 这些命令时,它工作正常。当我把它放到批处理文件中并自己执行时,它 运行 没问题。当我 运行 "Execute Windows Batch command" 中的命令时,它挂起并且不执行。
我怀疑它需要凭据。我不知道如何发送批处理命令的凭据。
我 set
命令,并且可以确认在 Jenkins 执行期间 运行ning 的用户与我 运行 在命令提示符。
如何将用户设置为 运行 此批处理命令?
默认情况下,Git for Windows will use as credential manager the Credential Manager of Windows, through the Git-Credential-Manager-for-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
这样,该存储库中的任何用户都将使用正确的凭据。
我在这上面花了很多时间。这不是 the cygwin post that is first on google search.
的副本正常 GIT Repo 使用凭据 - 我在 Jenkins 上有很多项目,使用 GIT,它们都工作正常。这些 repo 使用存储库 URL 和凭据和分支,显然使用 GIT 进行操作。
现在,我需要执行 GIT 命令。这是一个简单的 git tfs pull
和 git push.
当我在控制台中 运行 这些命令时,它工作正常。当我把它放到批处理文件中并自己执行时,它 运行 没问题。当我 运行 "Execute Windows Batch command" 中的命令时,它挂起并且不执行。
我怀疑它需要凭据。我不知道如何发送批处理命令的凭据。
我 set
命令,并且可以确认在 Jenkins 执行期间 运行ning 的用户与我 运行 在命令提示符。
如何将用户设置为 运行 此批处理命令?
默认情况下,Git for Windows will use as credential manager the Credential Manager of Windows, through the Git-Credential-Manager-for-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
这样,该存储库中的任何用户都将使用正确的凭据。