1
votes

So i have 11 repositories of 1 project, they are all micro-services.
I have one repository called DevOps where everything that has to be shared across YAML builds, is shared using a Git Submodule.
For some reason i cant seem to reference yaml templates that are in a git module.

Options:

enter image description here


When i try to run a build by trigger or manually i get the error:

File /DevOps/A/Templates/A-test-template.yml not found in repository http://A.azuredevops.local/DefaultCollection/A/_git/A branch refs/heads/master version db2884cc2d188b8e281f78e8b27e4fd74ce77d58.,Unexpected step type: 'StepsTemplateReference'

YAML:

steps:

# Run Unit Tests
- template: DevOps/A/Templates/A-test-template.yml



SOLUTION:

Using a YAML:

resources:
  repositories:
    - repository: RepositoryAlias
      type: git
      name: "ProjectName/RepositoryName"

steps:
- template: DevOps/A/Templates/A-test-template.yml@RepositoryAlias
1

1 Answers

5
votes

I think this wont work, because steps have to be calculated before build actually starts and submodules are being checked out after the build starts. But, honestly, you should just use a proper way of doing it (not submodules):

# Repo: Contoso/LinuxProduct
# File: azure-pipelines.yml
resources:
  repositories:
    - repository: templates
      type: github
      name: Contoso/BuildTemplates

jobs:
- template: common.yml@templates  # Template reference

So just put them in a separate repo and reference the repo.

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#using-other-repositories