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.
- All stages depend on 1 Powershell stage which does some work and sets some variables
- 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)
- 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:
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.
What could be a solution to this?
I tried using parameters and compile time variables but nothing worked. I still have the same error.
CodePudding user response:
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.