从Azure Pipeline

问题描述 投票:0回答:3

stages: - stage: checkout jobs: - job: checkout steps: - checkout: self submodules: true persistCredentials: true

然后,此尝试检查子模块,但以以下错误结尾:

Cloning into '/home/vsts/work/1/s/devops-scripting'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
fatal: clone of 'https://github.com/sourcerepo/devops-scripting.git' into submodule path '/home/vsts/work/1/s/devops-scripting' failed

它似乎是使用不正确的用户/密码的问题 - 如果我推动我可以简单地使用供应用户/通过参数,但是这似乎不起作用。

如何通过Azure管道更新子模块?
	

从Azure Pipeline

检查git subsodule

git azure azure-pipelines git-submodules
3个回答
9
投票
如果不是,您可以使用自定义脚本步骤获取子模型。首先,获取个人访问令牌(PAT),然后以Pat:。接下来,base64-对此前缀的字符串编写以创建基本的身份令牌。最后,将此脚本添加到您的管道中:

git -c http.https://<url of submodule repository>.extraheader="AUTHORIZATION: basic <BASE64_ENCODED_TOKEN_DESCRIBED_ABOVE>" submodule update --init --recursive

确保用您的base64编码令牌替换“

<BASIC_AUTH_TOKEN>

”。

使用项目中的秘密变量或构建管道来存储您生成的基本验证令牌。使用该变量在上述git命令中填充秘密。 其他解决方法,请使用自定义脚本重复使用访问令牌以进行subpodule同步:

steps:
- checkout: self
  submodules: false
  persistCredentials : true

- powershell: |
    $header = "AUTHORIZATION: bearer $(System.AccessToken)"
    git -c http.extraheader="$header" submodule sync
    git -c http.extraheader="$header" submodule update --init --force --depth=1

选中更多信息,请参阅此帖子。


贝洛方法支持在同一

阿多组织

中的不同

阿多项目中检查子模型。请注意,所有子模型都必须在

Https

- script: | git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" \ submodule update --init --recursive displayName: Fetch Submodules


2
投票
,该系统是从您的内部内部对VST进行了对VST验证的,并发行了

steps: - checkout: self persistCredentials: true this this Answer i我假设由于子模块存储库的性质而产生的问题:如果它是私人存储库,则需要克隆凭证。

我也有同样的问题。我在YAML管道中尝试了这一点:
steps:
- checkout: self
  submodules: true
  persistCredentials : true

1
投票
但是在我的Azure DevOps项目中,我还需要转到:1)

Project设置,2)SETTINGS。在那里,我禁用了选项:

在YAML Pipelines中保护对存储库的访问

从YAML管道访问存储库时,请进行支票和批准。此外,生成一个示为YAML Pipeline中明确引用的存储库的作业访问令牌。

然后起作用

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.