当我们在Azure DevOps中使用GitPython并尝试推送到存储库时,会出现以下消息(与管道克隆的存储库相同):
stderr: 'git: 'credential-manager-core' is not a git command. See 'git --help'.
基础架构:GitHub,Windows构建机器(最新)
由于我们的工作目录是当前克隆的存储库,因此我们以如下方式初始化存储库:
import git
repo = git.Repo('.')
# Do some stuff
repo.git.execute('git add --all -- ":!build-infrastructure"')
repo.git.execute(f'git commit -m "{generic_commit_message}"')
repo.git.execute('git push')
因此,推送更改应使用与用于拉取的Azure DevOps相同的凭据进行工作。我想念什么吗?
解决方案
解决方案是覆盖管道中的checkout
步骤:https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#checkout
steps:
- checkout: self
submodules: true
persistCredentials: true
答案 0 :(得分:1)
检查用于遥控器的URL已注册:repo.git.remote('-v')
可能是该网址是在提取时不需要凭据的网址。
检查配置如何设置:repo.git.config('-l')
,如果可以从$PATH
中获得目标可执行文件...
您可能需要在管道的设置部分中添加一些步骤(例如,安装上述凭据管理器)。
答案 1 :(得分:0)
解决方案
解决方案是覆盖管道中的结帐步骤:https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#checkout
steps:
- checkout: self
submodules: true
persistCredentials: true