There are two main ways to create re-usable components for Azure Pipelines. I’ll review the pros and cons of each and talk about when it makes sense to use one over the other. Keep in mind that the two are not mutually exclusive, so it may make sense to use a combination of both.

Note: I won’t be including task groups as they’re not supported in YAML pipelines. Why use YAML over Classic Editor? See my previous blog post here: Classic Editor VS. YAML

Custom pipeline task extension

Pros

Cons

Why would you use a custom pipeline task extension over a YAML template?

Pros

Cons

YAML template

Pros

Cons

Why would you use a YAML template over a custom pipeline task extension?

Pros

Cons

Use them together

Sometimes it makes sense to create a custom task extension, then reference it in templates. In that case, consumers can still use the task individually (outside of the template), but things like security can be enforced when it makes sense. I have some examples of this on GitHub; I have a template repo here, that get’s referenced in my YAML pipeline here.