1. What are Pipeline Resources in Azure DevOps?
In Azure DevOps YAML Pipelines, pipeline resources are external or related resources that a pipeline can reference and use during execution.
These resources may include:
-
Another Azure Pipeline
-
Git repositories
-
Build artifacts
-
Container images
-
Packages
Main purpose: Pipeline resources allow one pipeline to consume outputs or code from another source, helping us build reusable and interconnected CI/CD pipelines.
Real-time example
Suppose we have an ASP.NET Core Web API application with two pipelines:
-
Build Pipeline: Builds the application and publishes artifacts.
-
Deployment Pipeline: Downloads the build artifacts and deploys them to UAT or Production.
Instead of rebuilding the application, the deployment pipeline reuses the artifact generated by the Build Pipeline.
Developer Pushes Code
|
v
Build Pipeline (CI)
|
v
Build ASP.NET Core Web API
|
v
Publish Build Artifact
|
v
Pipeline Resource
|
v
Deployment Pipeline (CD)
|
v
Download Build Artifact
|
v
Deploy to UAT / Production
2. Types of Pipeline Resources
Azure DevOps supports the following YAML resource types:
|
Resource type |
Purpose |
|---|---|
|
|
Reference another Azure Pipeline and its artifacts |
|
|
Reference another Git repository |
|
|
Reference container images |
|
|
Reference packages from supported package feeds |
|
|
Reference artifacts from supported external build systems |
|
|
Trigger pipelines from external webhook events |
Resources are declared under the resources: section of the YAML file.
3. Pipeline Resource Example
Let's create two pipelines:
-
Build Pipeline — builds the Web API.
-
Deployment Pipeline — consumes the artifact.
Step 1: Build Pipeline
File: azure-build.yml
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '8.0.x'
- task: DotNetCoreCLI@2
displayName: 'Publish Web API'
inputs:
command: 'publish'
publishWebProjects: false
projects: 'src/MyWebAPI/MyWebAPI.csproj'
arguments: >
--configuration Release
--output $(Build.ArtifactStagingDirectory)/publish
zipAfterPublish: false
- publish: '$(Build.ArtifactStagingDirectory)/publish'
artifact: 'webapi'
displayName: 'Publish Artifact'
Explanation:
-
Builds and publishes the ASP.NET Core Web API.
-
Creates a pipeline artifact named
webapi. -
Makes the artifact available to other pipelines.
Step 2: Deployment Pipeline
File: azure-deploy.yml
trigger: none
resources:
pipelines:
- pipeline: webapiBuild
source: WebAPI-Build
trigger: true
pool:
vmImage: 'ubuntu-latest'
steps:
- download: webapiBuild
artifact: webapi
- script: |
echo "Artifact downloaded successfully"
echo "Ready for deployment"
Explanation:
|
Property |
Description |
|---|---|
|
|
Declares external resources |
|
|
Specifies pipeline resources |
|
|
Local alias for the referenced pipeline |
|
|
Name of the existing Azure Pipeline |
|
|
Triggers this pipeline when the source pipeline completes successfully |
|
|
Downloads artifacts from the referenced pipeline |
|
|
Specifies the artifact name |
The deployment pipeline downloads the artifact into:
$(Pipeline.Workspace)/webapiBuild/webapi
The example downloads the artifact but does not actually deploy it. A deployment task must be added for the target environment.
4. How Does Pipeline Resource Triggering Work?
Pipeline resource triggers allow one pipeline to start automatically after another pipeline completes successfully.
Build Pipeline
|
v
Build Application
|
v
Publish Artifact
|
v
Build Pipeline Succeeded?
|
+---- NO ---> Deployment Not Triggered
|
+---- YES
|
v
Pipeline Resource Trigger
|
v
Deployment Pipeline
|
v
Download Artifact
|
v
Deploy Application
Important: trigger: true under resources.pipelines is different from the top-level trigger: property.
-
Top-level
trigger:controls CI triggers from repository changes. -
resources.pipelines[*].triggercontrols triggers from another pipeline's completion.
5. Repository Resources
Repository resources allow a pipeline to access YAML templates or source code from another Git repository.
Example
Suppose common YAML templates are stored in a separate Azure Repos repository.
resources:
repositories:
- repository: sharedTemplates
type: git
name: MyProject/DevOps-Templates
ref: refs/heads/main
steps:
- template: templates/dotnet-build.yml@sharedTemplates
parameters:
projectPath: 'src/MyWebAPI/MyWebAPI.csproj'
Explanation:
-
sharedTemplatesis the repository alias. -
type: gitindicates Azure Repos Git. -
name:identifies the repository. -
ref:specifies the branch. -
@sharedTemplatesreferences the shared repository.
This is useful when multiple applications reuse a centralized CI/CD template.
6. Container Resources
Container resources define container images that pipeline jobs can use.
Example
resources:
containers:
- container: dotnetSDK
image: mcr.microsoft.com/dotnet/sdk:8.0
pool:
vmImage: 'ubuntu-latest'
container: dotnetSDK
steps:
- script: dotnet --version
Here, the job runs inside a container based on the .NET 8 SDK image.
Where is it used?
Container resources are useful when applications require consistent build environments, specific SDK versions, or containerized tooling.
7. Pipeline Resources vs Pipeline Artifacts
These concepts are related but different.
|
Feature |
Pipeline Resources |
Pipeline Artifacts |
|---|---|---|
|
Purpose |
Reference external pipelines or other resources |
Store and transfer build output files |
|
YAML syntax |
|
|
|
Can trigger pipelines |
Yes, supported resource types |
No, not independently |
|
Common usage |
Connect CI and CD pipelines |
Share compiled application files |
Example:
Build Pipeline
|
v
Creates Artifact
|
| webapi.zip
|
v
Pipeline Resource
|
v
Deployment Pipeline
|
v
Downloads Artifact
The pipeline artifact contains the application files. The pipeline resource identifies the source pipeline and allows the deployment pipeline to consume its outputs.
8. Advantages and Disadvantages
Advantages
-
Pipeline integration: Connect CI and CD pipelines.
-
Artifact reuse: Deploy the same tested build without rebuilding.
-
Automation: Trigger downstream pipelines automatically.
-
Reusability: Share common YAML templates across repositories.
-
Traceability: Identify the source pipeline run and artifact version.
Disadvantages
-
Dependency management: Downstream pipelines depend on source resources.
-
Permissions: Cross-project or external resources may require authorization.
-
Troubleshooting: Failures can involve multiple pipelines.
-
Version management: Resources must be referenced carefully to avoid consuming unintended versions.
9. Important Interview Questions and Answers
Q1. What are pipeline resources in Azure DevOps?
Pipeline resources are external or related resources, such as pipelines, repositories, containers, and packages, that a YAML pipeline can reference and consume.
Q2. Why do we use pipeline resources?
To reuse build artifacts, reference shared repositories, connect pipelines, and automate downstream workflows.
Q3. How do you trigger one pipeline after another pipeline completes?
Using a pipeline resource with trigger: true.
resources:
pipelines:
- pipeline: buildPipeline
source: WebAPI-Build
trigger: true
Q4. How do you download an artifact from another pipeline?
Declare the source as a pipeline resource and use:
- download: buildPipeline
artifact: webapi
Q5. What is the difference between pipeline resources and repository resources?
Pipeline resources reference other pipeline runs and their artifacts, while repository resources reference Git repositories containing code or YAML templates.
Q6. Can pipeline resources reference pipelines in another Azure DevOps project?
Yes. Use the project: property and ensure the necessary permissions are configured.
Q7. Can we deploy the same artifact to UAT and Production?
Yes. A deployment pipeline can consume the same build artifact for both environments, ensuring consistency between tested and production releases.
10. Key Points for Interview
-
Pipeline resources connect pipelines and external resources.
-
Resources are defined under
resources:. -
resources.pipelinesreferences another pipeline. -
resources.repositoriesreferences another Git repository. -
resources.containersreferences container images. -
trigger: trueenables pipeline-completion triggering. -
download:retrieves artifacts from referenced pipelines. -
CI and CD pipelines can be separated while reusing the same build artifacts.
Interview-ready answer
"In Azure DevOps, pipeline resources allow YAML pipelines to reference other pipelines, Git repositories, containers, and packages. They are commonly used to connect CI and CD workflows. For example, a Build Pipeline compiles an ASP.NET Core Web API and publishes an artifact. A Deployment Pipeline references the Build Pipeline using resources.pipelines, automatically starts when the build completes successfully, downloads the artifact, and deploys it to the required environment. This improves reusability, automation, and deployment consistency."
Official documentation: Azure Pipelines Resources — Microsoft Learn