microsoft / azure-pipelines-yaml

Azure Pipelines YAML examples, templates, and community interaction
MIT License
1.21k stars 934 forks source link

Yaml becomes invalid when specific `checkout:` syntax occurs more than once #582

Open Snijderman opened 1 year ago

Snijderman commented 1 year ago

Hi,

I've got this strange issue when trying multiple times to get sources from a repo in a yaml pipeline. This works if I use 'self' or a defined repository, but it doesn't work when using the following syntax:

checkout: git://$(repositoryName)@$(repositoryBranch)

This issue occurs when this syntax is present more than once in the pipeline. For example, this works:

stages:
   - stage: GetSourcesForStage1
     displayName: 'Get sources for stage 1'
     pool:
        name: $(poolName)
     jobs:
        - job: Stage1GetSources
          workspace:
             clean: all
          steps:
             - checkout: repositorySources

   - stage: GetSourcesForStage2
     displayName: 'Get sources for stage 2'
     dependsOn:
     pool:
        name: $(poolName)
     jobs:
        - job: Stage2GetSources
          workspace:
             clean: all
          steps:
             - checkout: repositorySources

and this also works;

stages:
   - stage: GetSourcesForStage1
     displayName: 'Get sources for stage 1'
     pool:
        name: $(poolName)
     jobs:
        - job: Stage1GetSources
          workspace:
             clean: all
          steps:
             - checkout: git://$(solutionRepository)@$(Build.SourceBranch)

   - stage: GetSourcesForStage2
     displayName: 'Get sources for stage 2'
     dependsOn:
     pool:
        name: $(poolName)
     jobs:
        - job: Stage2GetSources
          workspace:
             clean: all
          steps:
             - checkout: repositorySources

But this doesn't:

stages:
   - stage: GetSourcesForStage1
     displayName: 'Get sources for stage 1'
     pool:
        name: $(poolName)
     jobs:
        - job: Stage1GetSources
          workspace:
             clean: all
          steps:
             - checkout: git://$(solutionRepository)@$(Build.SourceBranch)

   - stage: GetSourcesForStage2
     displayName: 'Get sources for stage 2'
     dependsOn:
     pool:
        name: $(poolName)
     jobs:
        - job: Stage2GetSources
          workspace:
             clean: all
          steps:
             - checkout: git://$(solutionRepository)@$(Build.SourceBranch)

Validation in the online designer doesn't give any response when trying to validate it and when I try to run the pipeline, it gives this error:

image

I also played around with different workspace cleaning and dependsOn settings, but that doesn't change the result.

Looks like an issue or am I doing something wrong? (btw. we're using our own managed pools, don't know it that makes any difference)

I've attached a simple yaml file that produces the issue, __OwnManagedPool__ and __PathToRepository__ need to be replaced by a valid value. yaml-checkout-issue.zip

kirill-ivlev commented 1 year ago

Hi @Snijderman, thanks for reporting! We are working on more prioritized issues at the moment but will get back to this one soon.