Problem to solve: I have my own build pipeline defined in YAML and an old task group. Task Groups are simply sets of tasks that are not tight to a repo. However YAML does not support Task Groups.
Possible solution: Therefore I need to create a YAML template that I can reuse in my pipeline build. This YAML template will be a "translation" of the Task Group.
Problem of the solution: YAML Templates (as far as I understood) are simply YAML pipelines themselves. But this means that they are coupled to GIT repos, which I don't want! I just was a reusable set of tasks that I can reference from my build pipelines.
How do I create a template not tight to a repo in Azure Devops? Is there a flaw in this solution and you suggest another approach?
As @4c74356b41 mentioned there is nothing bad to keeping coupling to git. There is no other better way than keeping YAML template than in git repo. If you have sth common across project or organization, create separate repo just for templates. And yes you can point to specific template in that repo. Please take a look here
If you have repo Contoso/BuildTemplates
and `common.yml' there
# Repo: Contoso/BuildTemplates
# File: common.yml
parameters:
- name: 'vmImage'
default: 'ubuntu 16.04'
type: string
jobs:
- job: Build
pool:
vmImage: ${{ parameters.vmImage }}
steps:
- script: npm install
- script: npm test
you can refer to this template in another repo like this:
# Repo: Contoso/LinuxProduct
# File: azure-pipelines.yml
resources:
repositories:
- repository: templates
type: github
name: Contoso/BuildTemplates
jobs:
- template: common.yml@templates # Template reference
where common.yml
is name of the template and templates
is alias for your repo where you keep templates.
it worked! thanks a lot :)