[英]Azure Pipeline checkout same repo multiple times
I've been banging my head for DAYS on this.我已经为此苦苦思索了好几天。 Basically, this is my setup:基本上,这是我的设置:
- 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.