存储库的浅提取

grm*_*mbl 4 continuous-integration azure-devops azure-pipelines

我有一个使用模板的 Azure Pipeline (yaml),我试图弄清楚如何设置被克隆的实际存储库的提取深度。

resources:
  repositories:
    - repository: templates
      type: git
      name: 'DevOps/CICD'
      ref: refs/heads/develop
    - repository: self # sic!
      fetchDepth: 1
      clean: true`
Run Code Online (Sandbox Code Playgroud)

支持获取深度(vscode 扩展),但我似乎找不到任何关于它的详细文档..

Cra*_*own 11

另一种选择是将浅层提取设置添加到VariablesYAML 管道的部分中:

\n
variables:\n  Agent.Source.Git.ShallowFetchDepth: 1\n
Run Code Online (Sandbox Code Playgroud)\n

Azure Pipelines 将自动识别此设置并--depth=1在识别时将其用作参数git fetch

\n

请注意,这仅适用于 2022 年 9 月之前创建的管道 \xe2\x80\x93 在该日期之后创建的管道将自动获取深度为 1 的管道,因此不需要显式配置。

\n


grm*_*mbl 7

把它放在steps对我有用的下面:

steps:
  - checkout: self
    fetchDepth: 1
    clean: true
  - task: NuGetCommand@2
  ...
Run Code Online (Sandbox Code Playgroud)

结果是:

2019-01-17T09:21:45.1133753Z ##[command]git -c http.extraheader="AUTHORIZATION:bearer ***" fetch --tags --prune --progress --no-recurse-submodules --depth =1 原点

  • 注意:如果您使用标签,您下载的内容可能仍会超出您的预期。您可以通过使用“fetchTags: false”和“fetchDepth: 1”来禁用标签,如上所示。我执行了上述步骤,并且可以在管道输出中看到“--深度=1”,但它仍然下载太多,禁用标签为我修复了它! (2认同)