for*_*dya 3 git-submodules 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) 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
Run Code Online (Sandbox Code Playgroud)
我也尝试过添加存储库 self 和
steps:
- checkout: self
submodules: true
persistCredentials: true
Run Code Online (Sandbox Code Playgroud)
forvaidya的答案对我不起作用(尽管现在已经是四年后了)。(中的相对 URL通过.gitmodules
解析为完整 URL 。).git/config
git submodule sync
persistCredentials: true
将使授权标头在git config
以后的步骤中可用,但它由您的主存储库 URL 键入。只要子模块存储库位于同一组织中,您就可以重用标头 - 例如在管道 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
Run Code Online (Sandbox Code Playgroud)
(我从标准步骤的日志中收集了这些详细信息checkout
。请注意对Build.Repository.Uri
。)
上面将完成主存储库的完整(“非浅度”)签出(对于例如GitVersion很有用)很有用),没有子模块,以及任何子模块的浅度签出。
编辑:获取授权标头的记录方法是
$header = "AUTHORIZATION: bearer $(System.AccessToken)"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3302 次 |
最近记录: |