I know that we can verify extend template used or not at deployment stage on targeted azure devops environment using extend template check.
I have a requirement to verify or run this check at run time before any of the build task starts i.e. when user run the build . I've asked similar question here Azure pipeline build Stage verification but as a centralized compliance team we want to block user from running the build if they are not extending certain template.

- 415
- 5
- 17
1 Answers
You can achieve above requirement by setting a template check for the agent pools. If a agent pool is configured approvals and checks, then all the jobs that targeting this agent pools will need to validate the approvals and checks before running.
You can follow below steps to set approvals and checks for agent pools.
Go to Project settings --> Agent pools under Pipelines-->Select the agent pools(eg. Azure Pipelines).
Click the 3dots on the top right corner--> Click Approvals and checks--> Click the plus sign to Add a template check.
Then all the jobs that targeting an agent in this agent pool will have to pass the template checks before running on the agent.
Note: Please make sure the Multi-stage pipelines experience is turned on. Check the document here here to turn on or off the Preview features.

- 27,483
- 2
- 31
- 43
-
Thsi feature definitely solves the problem but it has bugs https://stackoverflow.com/questions/60699631/extend-template-check-at-agent-pools-in-azure-pipelines – Sanjeev Mar 16 '20 at 19:17