Azure Pipelines Tasks Reference
This document provides a reference for commonly used built-in Azure Pipelines tasks.
How to Use This Reference
Use this deterministic flow:
- Start from
Task Syntax. - Jump to only the task family needed for the current pipeline.
- Copy a minimal example and adjust inputs.
- Keep task major versions pinned (
Task@N). - Validate with
azure-pipelines-validatorafter editing.
Fallback behavior:
- If a required task is not listed here, look up official docs (Microsoft Learn) and note the source.
- If external lookup is unavailable, keep the nearest known task pattern and mark uncertainty in assumptions.
- If input compatibility is unclear, prefer the latest documented stable major and avoid undocumented inputs.
Task Syntax
- task: TaskName@MajorVersion
displayName: 'Human Readable Name'
inputs:
inputName: value
anotherInput: value
condition: succeeded()
continueOnError: false
enabled: true
env:
ENV_VAR: value
timeoutInMinutes: 0.NET/C# Tasks
DotNetCoreCLI@2
Build, test, package, or publish a .NET Core project.
- task: DotNetCoreCLI@2
displayName: 'Restore NuGet packages'
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration Release'
- task: DotNetCoreCLI@2
displayName: 'Run Tests'
inputs:
command: 'test'
projects: '**/*Tests/*.csproj'
arguments: '--configuration Release --collect:"XPlat Code Coverage"'
- task: DotNetCoreCLI@2
displayName: 'Publish'
inputs:
command: 'publish'
projects: '**/*.csproj'
arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: trueNuGetCommand@2
Restore, pack, or push NuGet packages.
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
- task: NuGetCommand@2
displayName: 'NuGet pack'
inputs:
command: 'pack'
packagesToPack: '**/*.nuspec'
versioningScheme: 'byBuildNumber'Node.js/JavaScript Tasks
NodeTool@0
Install a specific Node.js version.
- task: NodeTool@0
displayName: 'Use Node.js 20.x'
inputs:
versionSpec: '20.x'Npm@1
Run npm commands.
- task: Npm@1
displayName: 'npm install'
inputs:
command: 'install'
- task: Npm@1
displayName: 'npm run build'
inputs:
command: 'custom'
customCommand: 'run build'
- task: Npm@1
displayName: 'npm test'
inputs:
command: 'custom'
customCommand: 'run test'Python Tasks
UsePythonVersion@0
Select a Python version to run on an agent.
- task: UsePythonVersion@0
displayName: 'Use Python 3.11'
inputs:
versionSpec: '3.11'
addToPath: true
architecture: 'x64'Pip@1 / Script
Install Python packages.
- script: |
python -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'
- script: pytest tests/ --junitxml=junit/test-results.xml
displayName: 'Run tests'Docker Tasks
Docker@2
Build, push, or run Docker images.
# Login to registry
- task: Docker@2
displayName: 'Docker Login'
inputs:
command: 'login'
containerRegistry: 'myDockerRegistryServiceConnection'
# Build image
- task: Docker@2
displayName: 'Build Docker image'
inputs:
command: 'build'
repository: 'myrepo/myimage'
dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
tags: |
$(Build.BuildId)
$(Build.SourceVersion)
# Push image
- task: Docker@2
displayName: 'Push Docker image'
inputs:
command: 'push'
repository: 'myrepo/myimage'
tags: |
$(Build.BuildId)
$(Build.SourceVersion)
# Build and push (combined)
- task: Docker@2
displayName: 'Build and Push'
inputs:
command: 'buildAndPush'
repository: 'myrepo/myimage'
dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
containerRegistry: 'myDockerRegistryServiceConnection'
tags: |
$(Build.BuildId)
$(Build.SourceVersion)DockerCompose@0
Build, push, or run multi-container Docker applications.
- task: DockerCompose@0
displayName: 'Run Docker Compose'
inputs:
action: 'Run services'
dockerComposeFile: 'docker-compose.yml'
projectName: '$(Build.Repository.Name)'
qualifyImageNames: true
buildImages: trueKubernetes Tasks
Kubernetes@1
Deploy, configure, or update a Kubernetes cluster.
- task: Kubernetes@1
displayName: 'kubectl apply'
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: 'myK8sConnection'
command: 'apply'
arguments: '-f manifests/'
- task: Kubernetes@1
displayName: 'kubectl set image'
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: 'myK8sConnection'
command: 'set'
arguments: 'image deployment/myapp myapp=$(containerRegistry)/myimage:$(Build.BuildId)'KubernetesManifest@0
Bake and deploy Kubernetes manifests.
- task: KubernetesManifest@0
displayName: 'Deploy to Kubernetes'
inputs:
action: 'deploy'
kubernetesServiceConnection: 'myK8sConnection'
namespace: 'production'
manifests: |
manifests/deployment.yml
manifests/service.yml
containers: '$(containerRegistry)/myimage:$(Build.BuildId)'HelmDeploy@0
Deploy using Helm charts.
- task: HelmDeploy@0
displayName: 'Helm deploy'
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: 'myK8sConnection'
namespace: 'production'
command: 'upgrade'
chartType: 'FilePath'
chartPath: '$(Build.SourcesDirectory)/charts/myapp'
releaseName: 'myapp'
arguments: '--set image.tag=$(Build.BuildId)'Azure Tasks
AzureCLI@2
Run Azure CLI commands.
- task: AzureCLI@2
displayName: 'Azure CLI'
inputs:
azureSubscription: 'myAzureServiceConnection'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az --version
az account showAzurePowerShell@5
Run Azure PowerShell commands.
- task: AzurePowerShell@5
displayName: 'Azure PowerShell'
inputs:
azureSubscription: 'myAzureServiceConnection'
scriptType: 'inlineScript'
inline: |
Get-AzResourceGroup
azurePowerShellVersion: 'LatestVersion'AzureWebApp@1
Deploy to Azure App Service.
- task: AzureWebApp@1
displayName: 'Deploy to Azure Web App'
inputs:
azureSubscription: 'myAzureServiceConnection'
appType: 'webAppLinux'
appName: 'mywebapp'
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'AzureFunctionApp@1
Deploy to Azure Functions.
- task: AzureFunctionApp@1
displayName: 'Deploy Azure Function'
inputs:
azureSubscription: 'myAzureServiceConnection'
appType: 'functionAppLinux'
appName: 'myfunctionapp'
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'AzureRmWebAppDeployment@4
Advanced Azure App Service deployment.
- task: AzureRmWebAppDeployment@4
displayName: 'Azure App Service Deploy'
inputs:
azureSubscription: 'myAzureServiceConnection'
appType: 'webAppLinux'
WebAppName: 'mywebapp'
packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
RuntimeStack: 'NODE|20-lts'Build and Artifact Tasks
PublishBuildArtifacts@1
Publish build artifacts to Azure Pipelines.
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'DownloadBuildArtifacts@1
Download build artifacts.
- task: DownloadBuildArtifacts@1
displayName: 'Download Build Artifacts'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'PublishPipelineArtifact@1
Publish artifacts (preferred over PublishBuildArtifacts).
- task: PublishPipelineArtifact@1
displayName: 'Publish Pipeline Artifact'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifact: 'drop'
publishLocation: 'pipeline'DownloadPipelineArtifact@2
Download pipeline artifacts (preferred over DownloadBuildArtifacts).
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact'
inputs:
buildType: 'current'
artifactName: 'drop'
targetPath: '$(Pipeline.Workspace)'Test and Code Coverage Tasks
PublishTestResults@2
Publish test results.
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/test-results.xml'
searchFolder: '$(System.DefaultWorkingDirectory)'
mergeTestResults: true
failTaskOnFailedTests: truePublishCodeCoverageResults@1
Publish code coverage results.
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage'
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'Utility Tasks
CopyFiles@2
Copy files to a target folder.
- task: CopyFiles@2
displayName: 'Copy Files'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
**/*.js
**/*.json
!node_modules/**
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: trueDeleteFiles@1
Delete files from the agent.
- task: DeleteFiles@1
displayName: 'Delete Files'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
**/node_modules
**/tempCache@2
Cache files and restore them in future runs.
- task: Cache@2
displayName: 'Cache npm'
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(Pipeline.Workspace)/.npm
- task: Cache@2
displayName: 'Cache Maven'
inputs:
key: 'maven | "$(Agent.OS)" | **/pom.xml'
restoreKeys: |
maven | "$(Agent.OS)"
path: $(Pipeline.Workspace)/.m2/repositoryPowerShell@2 / Bash@3
Run PowerShell or Bash scripts.
- task: PowerShell@2
displayName: 'Run PowerShell Script'
inputs:
targetType: 'inline'
script: |
Write-Host "Running PowerShell"
Get-ChildItem -Path $(Build.SourcesDirectory)
- task: Bash@3
displayName: 'Run Bash Script'
inputs:
targetType: 'inline'
script: |
echo "Running Bash"
ls -la $(Build.SourcesDirectory)Security Tasks
SonarCloudPrepare@1 / SonarCloudAnalyze@1
SonarCloud code analysis.
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'SonarCloud'
organization: 'myorg'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'myproject'
cliProjectName: 'My Project'
- task: SonarCloudAnalyze@1
displayName: 'Run SonarCloud Analysis'
- task: SonarCloudPublish@1
displayName: 'Publish SonarCloud Results'
inputs:
pollingTimeoutSec: '300'WhiteSource@21
WhiteSource security and license scanning.
- task: WhiteSource@21
inputs:
cwd: '$(Build.SourcesDirectory)'
projectName: 'MyProject'Version Control Tasks
GitHubRelease@1
Create a GitHub release.
- task: GitHubRelease@1
displayName: 'Create GitHub Release'
inputs:
gitHubConnection: 'GitHubServiceConnection'
repositoryName: '$(Build.Repository.Name)'
action: 'create'
target: '$(Build.SourceVersion)'
tagSource: 'gitTag'
tag: '$(Build.BuildNumber)'
title: 'Release $(Build.BuildNumber)'
releaseNotesSource: 'inline'
releaseNotesInline: 'Release notes here'
assets: '$(Build.ArtifactStagingDirectory)/**'Best Practices
- Pin task versions: Always specify the task major version and use the latest supported major for that task (for example,
Docker@2;@0is valid when that task only ships major0) - Use displayName: Add clear display names for all tasks
- Cache dependencies: Use Cache@2 for package managers
- Use conditions: Control task execution with conditions
- Set timeouts: Prevent hung tasks with timeoutInMinutes
- Use service connections: Store credentials in service connections, not in pipeline
- Publish test results: Always publish test results for visibility
- Use artifact tasks: Prefer PublishPipelineArtifact over PublishBuildArtifacts
- Error handling: Use continueOnError for non-critical tasks
- Environment variables: Pass sensitive data via env, not as task inputs
Finding Task Documentation
For detailed task documentation, use this order:
- Context7: Resolve library ID, then query task-specific docs.
- Official Task Reference: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/
- Task Source Code: https://github.com/microsoft/azure-pipelines-tasks
- Targeted web search:
"[TaskName] Azure Pipelines task documentation"(prefer Microsoft Learn URLs)
Task Versioning
Tasks follow semantic versioning:
# Major version (recommended)
- task: TaskName@2
# Full version (for specific fixes)
- task: TaskName@2.3.1Pin a known-compatible major version for your environment. Upgrade deliberately after compatibility checks.
Custom Tasks
You can also create and use custom tasks from:
- Azure DevOps Marketplace
- Private extensions
- YAML templates
# Marketplace task
- task: PublisherName.ExtensionName.TaskName@version
# Template as reusable task
- template: templates/my-custom-task.yml
parameters:
parameter1: valueDone Criteria
Use of this reference is complete when:
- The selected task examples match the requested pipeline mode.
- Task majors are pinned and inputs are explicitly set where required.
- Any missing-task assumptions or external-source lookups are documented.
- The resulting pipeline is validated with
azure-pipelines-validator(or documented manual fallback).