简体   繁体   English

Azure 管道多次检查相同的回购协议

[英]Azure Pipeline checkout same repo multiple times

I've been banging my head for DAYS on this.我已经为此苦苦思索了好几天。 Basically, this is my setup:基本上,这是我的设置:

  • I have a master pipeline that is divided in 10-15 stages, you can select which ones to run.我有一个分为 10-15 个阶段的主管道,您可以 select 运行哪些。
  • All stages depend on 1 Powershell stage which does some work and sets some variables所有阶段都依赖于 1 Powershell 阶段,它做一些工作并设置一些变量
  • Each stage (except the Powershell one) calls a template, which calls another BIG template (some stages may call the same BIG template or a different one)每个阶段(Powershell 除外)调用一个模板,该模板调用另一个 BIG 模板(某些阶段可能调用相同的 BIG 模板或不同的模板)
  • My problem resides on the "checkout" step:我的问题在于“结帐”步骤:
- checkout: git://Project/${{parameters.RepositoryToCheckOut}}@$(Build.SourceBranch)
   path: PathSpecified

Both the branch and repository variables need to be dynamic in some way.分支变量和存储库变量都需要在某种程度上是动态的。

This step is performed multiple times if two or more stages are selected, which prompts this error on Azure DevOps:如果选择了两个或多个阶段,则会多次执行此步骤,从而在 Azure DevOps 上提示此错误:

An error occurred while loading the YAML build pipeline. An item with the same key has already been added.

I read on some documents that it's some kind of key/value issue and I have no idea how to overcome it.我在一些文件上读到这是某种键/值问题,我不知道如何克服它。 I want to refrain from using a simple bash step and manually checkout since these files are very important and there's no margin for error.我想避免使用简单的 bash 步骤和手动签出,因为这些文件非常重要并且没有错误余地。

What could be a solution to this?什么可以解决这个问题?

I tried using parameters and compile time variables but nothing worked.我尝试使用参数和编译时变量,但没有任何效果。 I still have the same error.我仍然有同样的错误。

Issue was solved by using this:使用这个解决了问题:

- checkout: git://ProjectName/${{parameters.RepositoryToCheckout}}@${{ variables['Build.SourceBranch'] }}

Apparently this tricks the pipeline and it just works, I can't even explain it properly myself to be honest.显然这会欺骗管道并且它只是工作,老实说,我什至无法自己正确解释它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 事件触发器多次触发同一个文件 - Azure Event Trigger fires multiple times same file 跳过远程 azure 管道模板存储库中的步骤 - Skip steps from remote azure pipeline template repo Azure Devops:如何配置我的管道脚本以触发具有不同 repo 的另一个管道? - Azure Devops: how configure my pipeline script to trigger another pipeline with different repo? Azure Devops Release Pipeline 中针对不同分支的多个调度 - Multiple schedules in Azure Devops Release Pipeline for different branches GitLab-CI 管道在同一作业中无法识别 Azure CLI 和 Terraform - GitLab-CI Pipeline Not Recognizing Azure CLI and Terraform in Same Job 使用 YAML 管道构建和部署多个 azure function 项目 - Build and Deploy multiple azure function projects using YAML pipeline 我们能否在一个 azure-pipeline yaml 文件中为一个 repo 设置两个 Build.ArtifactStagingDirectory 位置以发布两个不同的 debian 安装程序 - Can we have two Build.ArtifactStagingDirectory location for one repo in one azure-pipeline yaml file to publish two different debian installer Azure 构建管道和发布管道nodejs - Azure build pipeline and release pipeline nodejs Python BigQuery 客户端多次执行相同的查询 - Python BigQuery client executing same query multiple times 如何从同一个 io.Reader 读取多次 - How to read multiple times from same io.Reader
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM