git - 尝试执行多次 checkout 时,Azure Pipeline 会创建第二个源代码文件夹 (Build.SourcesDirectory)

标签 git azure yaml pipeline checkout

我正在尝试运行 Azure 管道,需要在其中 checkout 两个存储库。该管道有 3 个作业。第一个作业只是检查我需要的许可证是否存在,然后第二个作业开始编译我的代码,第三个作业将其发布为 NuGet 包。

当我尝试运行管道时,它似乎工作正常,直到发布作业,它找不到规范文件。发生这种情况是因为对于第三个作业,变量 $(Build.SourcesDirectory) 指向 agent/_work/1/s,而代码在第二个作业期间 check out 代理/_work/2/s。由于某种原因,当我尝试 checkout 多个存储库时,第二个作业会创建第二个工作文件夹。

我已经尝试过仅使用一个存储库,并且运行良好(始终使用 agent/_work/1/s)。一旦我添加要 checkout 的第二个存储库,它就会创建第二个文件夹并与 Build.SourcesDirectory 变量混淆。

非常感谢任何帮助!

pool:
  name: myPool
   
jobs:
- job: check_license
  displayName: Check license
  steps:
  - checkout: none
  - powershell: |
      run something
    displayName: Check license
    
- job: compile_code
  displayName: Compile code
  dependsOn: check_license
  steps:
  - checkout: self
    path: ./s
    clean: true
  - checkout: git://myRepo
    path: ./s/myRepo
    clean: true
  - powershell: |
      run something
    displayName: Compiling code
      
- job: publish_code
  displayName: Publish code
  dependsOn: compile_code
  steps:
  - checkout: none
  - powershell: |

      # Configuration file
      $nuspecFile = "\artifact_spec.nuspec"

      # Copy file to build folder
      Copy-Item "$(Build.SourcesDirectory)\$nuspecFile" -Destination $(Build.BinariesDirectory)
      
      ...
    displayName: Publish NuGet package 

最佳答案

我在这里找到了一个解决方案: https://developercommunity.visualstudio.com/t/checkout-step-creates-new-directory-in-work-every/1084115?viewtype=solutions

基本上,解决方案是仅 checkout 一个存储库,然后在脚本中使用 git 命令克隆第二个存储库。

关于git - 尝试执行多次 checkout 时,Azure Pipeline 会创建第二个源代码文件夹 (Build.SourcesDirectory),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73461081/

相关文章:

git - 使用 ldirectord 对 GIT 服务器进行负载平衡

docker - 发布构建工件任务结果 'path does not exist'错误

git - 如何存储我的 key 的密码,以便在 Windows 上使用 git 时可以提交和从存储库中提取?

git - 为此我需要两个 GitHub 帐户吗?

具有多个祖先和kdiff3的git递归策略

azure - 有没有办法在java/python代码中使用SAS(共享访问签名)URI访问azure blob存储

json - 指导如何实际加密 APNS 的 JSON token

azure - 使用powershell创建HDCluster

xml - 如何将 xml symfony 服务文件转换为 yaml

c# - Docker如何部署dotnet nginx? (不带.csproj)