Hello Arafat Mohammed,
Thank you for posting your question in the Microsoft Q&A forum.
Yes, referencing YAML templates across Azure DevOps projects is fully supported. Your approach is fundamentally correct but needs these adjustments:
Service Connection Configuration:
- Use "Azure Repos/Team Foundation Server" type (not "Other Git")
- The endpoint URL should be just *https://dev.azure.com/[org]*
- PAT needs Build (Read) permission, not just Code (Read)
Repository Resource Syntax (yaml):
resources:
- repository: templates
type: git
name: DevOps/FrontendApp-Pipeline
ref: main # explicit branch reference
The challenge of reusing YAML pipeline templates across different Azure DevOps projects within the same organization represents a common architectural need for many development teams. While Azure DevOps does support this functionality, proper implementation requires careful attention to several configuration details that differ from standard intra-project template references.
The fundamental architecture involves declaring the external repository as a resource in your pipeline configuration. This approach leverages Azure DevOps' built-in capabilities for cross-project collaboration, but success depends on three critical elements: the correct service connection type, appropriate permissions, and precise reference syntax. The service connection must be configured as "Azure Repos/Team Foundation Server" rather than the more generic "Other Git" option, with authentication handled through a Personal Access Token that includes Build (Read) permissions rather than just basic Code access.
Alternative Approaches:
- Extension Method: Package templates as a custom extension
- GitHub Mirror: Push templates to a GitHub repo (simpler auth model)
- Pipeline Artifacts: Publish templates as build artifacts and download them
If the above answer helped, please do not forget to "Accept Answer" as this may help other community members to refer the info if facing a similar issue. Your contribution to the Microsoft Q&A community is highly appreciated.