DEV Community 👩‍💻👨‍💻

DEV Community 👩‍💻👨‍💻 is a community of 967,611 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Kenichiro Nakamura
Kenichiro Nakamura

Posted on

Azure DevOps YAML pipeline : Template = task group

When I author build/release pipelines, I often used task group so that I can reuse the set of tasks in multiple pipelines.

Since last year, I switched to use YAML pipeline instead of GUI, and all of sudden, I need to say good-bye to task group, and say hello to Template

In this article, I create a repository which contains a set of shared .yml files for reuse.

Setup Azure DevOps

I have two repositories:

  • myapp: Store my application. I just put a text file for now.
  • taskgroup: Store shared yml.

Create shared yml file

I usually create pipeline yml by using pipeline editor as it has IntelliSense support.

1. Go to Pipelines and click New pipeline.

2. Select "Azure Repos Git".

3. Select "taskgroup" repository.

4. Select "Starter pipeline".

5. Change the file name to hello-user.yml and replace the code. This could be the simplest yml with a parameter. See Parameters for more detail.

  - name: yourName
    type: string
    default: 'world'

  - script: echo Hello ${{ parameters.yourName}}
    displayName: 'Hello user'

6. Save the change to commit the file.

Create consumer pipeline

Next, I author a pipeline in myapp repository and use hellp-user.yml.

1. Go to Pipelines and click New pipeline.

2. Select "Azure Repos Git".

3. Select "myapp" repository.

4. Select "Starter pipeline".

5. Update the code. I keep the file name for now.

  • Use resources to reference taskgroup repository
  • The type is git which means AzureDevOps repository in this case
  • Use @ to reference the yml
  • Use parameters to set parameter values.
- master

    - repository: taskgroup
      type: git
      name: taskgroup

  vmImage: 'ubuntu-latest'

- script: echo Hello, world!
  displayName: 'Run a one-line script'

- template: hello-user.yml@taskgroup
    yourName: 'ken'

6. Save and run the pipeline.


When I run the pipeline, I can see that the pipeline references both myapp and taskgroup repositories.

Alt Text

I also confirmed that the shared yml ran as expected with correct parameter value.

Alt Text


I can use template as if it's task group. The biggest difference for me is that I can move the shared tasks easier as it's all stored as source code.

Top comments (0)

Update Your DEV Experience Level:


Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠