Azure devops 使用托管代理在管道上更新Git子模块
我有一个自托管代理和一个带有子模块的git存储库。.gitmodules中的URL是http:// 当我尝试初始化作业时,它无法更新子模块Azure devops 使用托管代理在管道上更新Git子模块,azure-devops,azure-devops-self-hosted-agent,Azure Devops,Azure Devops Self Hosted Agent,我有一个自托管代理和一个带有子模块的git存储库。.gitmodules中的URL是http:// 当我尝试初始化作业时,它无法更新子模块 git submodule sync git submodule update --init --force Cloning into 'foo-dev-common'... Submodule 'foo-dev-common' (https://MY_ORG@dev.azure.com/MY_ORG/PInC/_git/foo-dev-common) re
git submodule sync
git submodule update --init --force
Cloning into 'foo-dev-common'...
Submodule 'foo-dev-common' (https://MY_ORG@dev.azure.com/MY_ORG/PInC/_git/foo-dev-common) registered for path 'foo-dev-common'
fatal: could not read Password for 'https://MY_ORG@dev.azure.com': terminal prompts disabled
fatal: clone of 'https://MY_ORG@dev.azure.com/MY_ORG/PInC/_git/foo-dev-common' into submodule path 'foo-dev-common' failed
##[error]Git submodule update failed with exit code: 128
Finishing: Checkout foo-rose-identity-service@submod_bd_mahesh to s/foo-rose-identity-service
我还尝试添加存储库和self
steps:
- checkout: self
submodules: true
persistCredentials: true
在使git子模块相对路径正常工作之后
url= ../foo-dev-common
而不是
url=https://MY_ORG@dev.azure.com/MY_ORG/PInC/_git/foo-dev-common
在使git子模块相对路径正常工作之后
url= ../foo-dev-common
而不是
url=https://MY_ORG@dev.azure.com/MY_ORG/PInC/_git/foo-dev-common
福瓦迪亚的回答对我来说不起作用,尽管现在已经是4年后的事了。 git子模块sync将.gitmodules中的相对URL解析为.git/config中的完整URL persistCredentials:true将使授权头在git配置中可用,以备将来使用,但它由主repo URL设置密钥。只要子模块repo在同一个组织中,您就可以重用标头-例如,在管道Powershell脚本中:
steps:
- checkout: self
submodules: false
persistCredentials : true
- powershell: |
$header = $(git config --get-all http.$(Build.Repository.Uri).extraheader)
git -c http.extraheader="$header" submodule sync
git -c http.extraheader="$header" submodule update --init --force --depth=1
我从标准结帐步骤的日志中收集了这些细节。注意对Build.Repository.Uri管道变量的引用
上述内容将完成对主要回购协议的完全不允许签出,例如,无子模块,以及对任何子模块的浅签出
git submodule sync
git submodule update --init --force
Cloning into 'foo-dev-common'...
Submodule 'foo-dev-common' (https://MY_ORG@dev.azure.com/MY_ORG/PInC/_git/foo-dev-common) registered for path 'foo-dev-common'
fatal: could not read Password for 'https://MY_ORG@dev.azure.com': terminal prompts disabled
fatal: clone of 'https://MY_ORG@dev.azure.com/MY_ORG/PInC/_git/foo-dev-common' into submodule path 'foo-dev-common' failed
##[error]Git submodule update failed with exit code: 128
Finishing: Checkout foo-rose-identity-service@submod_bd_mahesh to s/foo-rose-identity-service
编辑:获取授权标头的方法是
$header = "AUTHORIZATION: bearer $(System.AccessToken)"
福瓦迪亚的回答对我来说不起作用,尽管现在已经是4年后的事了。 git子模块sync将.gitmodules中的相对URL解析为.git/config中的完整URL persistCredentials:true将使授权头在git配置中可用,以备将来使用,但它由主repo URL设置密钥。只要子模块repo在同一个组织中,您就可以重用标头-例如,在管道Powershell脚本中:
steps:
- checkout: self
submodules: false
persistCredentials : true
- powershell: |
$header = $(git config --get-all http.$(Build.Repository.Uri).extraheader)
git -c http.extraheader="$header" submodule sync
git -c http.extraheader="$header" submodule update --init --force --depth=1
我从标准结帐步骤的日志中收集了这些细节。注意对Build.Repository.Uri管道变量的引用
上述内容将完成对主要回购协议的完全不允许签出,例如,无子模块,以及对任何子模块的浅签出
git submodule sync
git submodule update --init --force
Cloning into 'foo-dev-common'...
Submodule 'foo-dev-common' (https://MY_ORG@dev.azure.com/MY_ORG/PInC/_git/foo-dev-common) registered for path 'foo-dev-common'
fatal: could not read Password for 'https://MY_ORG@dev.azure.com': terminal prompts disabled
fatal: clone of 'https://MY_ORG@dev.azure.com/MY_ORG/PInC/_git/foo-dev-common' into submodule path 'foo-dev-common' failed
##[error]Git submodule update failed with exit code: 128
Finishing: Checkout foo-rose-identity-service@submod_bd_mahesh to s/foo-rose-identity-service
编辑:获取授权标头的方法是
$header = "AUTHORIZATION: bearer $(System.AccessToken)"
非常感谢在这里分享这个解决方案。你可以,这样其他人可以直接知道这是工作。非常感谢在这里分享这个解决方案。您可以,以便其他人可以直接知道这是工作。我将此答案添加到我找到的解决方案列表中:我将此答案添加到我找到的解决方案列表中: