【问题标题】:How to check out submodules on azure pipeline?如何检查 azure 管道上的子模块?
【发布时间】:2020-05-01 08:58:05
【问题描述】:

我已阅读此内容,https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/pipeline-options-for-git?view=azure-devops,但作为 Azure 初学者,它不是很有帮助。

我在 GitHub 中有两个存储库,一个通过子模块引用另一个。我已授予 Azure Pipelines 对 GitHub 中两个存储库的访问权限。

我已经按照Getting Started Guide 制作了一个新管道,并且它在我的存储库中添加了一个azure-pipelines.yml。它看起来像这样:

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

我的.gitmodules 看起来像这样:

[submodule "src/MySubmodulePath"]
    path = src/MySubmodulePath
    url = git@github.com:trullock/MySubmoduleProject.git

但我已将其更改为使用 HTTPS,就像提到的那样:

[submodule "src/MySubmodulePath"]
    path = src/MySubmodulePath
    url = https://github.com/trullock/MySubmoduleProject.git

我仍然可以在 Pipelines 中的 Job 的 Checkout 步骤中看到,它没有检查子模块,因为构建失败,因为它们丢失了:

git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules origin

我已阅读此 https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#checkout 并且可以看到它显示了 submodules: true|recursive 设置,但我应该把它放在哪里?

将它放在steps 键下会导致构建时出现语法错误。

【问题讨论】:

    标签: azure-devops


    【解决方案1】:

    我遇到了类似的问题,但我需要启用 LFS,但配置应该以相同的方式工作。

    在你的情况下,这将是:

    steps:
    - checkout: self
      submodules: true
    

    【讨论】:

    • 谢谢,正是我需要的。想象一下,如果文档有示例!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-26
    • 2021-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-31
    相关资源
    最近更新 更多