Tasks for builds and releases
Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, service connections are called service endpoints, stages are called environments, and jobs are called phases.
A task is the building block for defining automation in a build pipeline, or in a stage of a release pipeline. A task is simply a packaged script or procedure that has been abstracted with a set of inputs.
When you add a task to your build or release pipeline, it may also add a set of demands to the pipeline. The demands define the prerequisites that must be installed on the agent for the task to run. When you run the build or deployment, an agent that meets these demands will be chosen.
When you queue a build or a deployment, all the tasks are run in sequence, one after the other, on an agent. To run the same set of tasks in parallel on multiple agents, or to run some tasks without using an agent, see jobs.
In addition, Visual Studio Marketplace offers a number of extensions; each of which, when installed to your subscription or collection, extends the task catalog with one or more tasks. Furthermore, you can write your own custom extensions to add tasks to Azure Pipelines or TFS.
In YAML pipelines, you refer to tasks by name. If a name matches both an in-box task and a custom task, the in-box task will take precedence. You can use a fully-qualified name for the custom task to avoid this risk:
steps: - task: myPublisherId.myExtensionId.myTaskName@1
Tasks are versioned, and you must specify the major version of the task used in your pipeline. This can help to prevent issues when new versions of a task are released. Tasks are typically backwards compatible, but in some scenarios you may encounter unpredictable errors when a task is automatically updated.
When a new minor version is released (for example, 1.2 to 1.3), your build or release will automatically use the new version. However, if a new major version is released (for example 2.0), your build or release will continue to use the major version you specified until you edit the pipeline and manually change to the new major version. The build or release log will include an alert that a new major version is available.
In YAML, you specify the major version using
@ in the task name.
For example, to pin to version 2 of the
steps: - task: PublishTestResults@2
Task control options
Each task offers you some Control Options.
Control options are available as keys on the
- task: string # reference to a task and version, e.g. "VSBuild@1" condition: expression # see below continueOnError: boolean # 'true' if future steps should run even if this step fails; defaults to 'false' enabled: boolean # whether or not to run this step; defaults to 'true' timeoutInMinutes: number # how long to wait before timing out the task
The timeout period begins when the task starts running. It does not include the time the task is queued or is waiting for an agent.
For the full schema, see YAML schema for
Only when all previous tasks have succeeded
Even if a previous task has failed, unless the build or release was canceled
Even if a previous task has failed, even if the build was canceled
Only when a previous task has failed
Build tool installers (Azure Pipelines)
Azure Pipelines preview feature
To use this capability you must be working on Azure Pipelines and enable the Task tool installers preview feature.
Tool installers enable your build pipeline to install and control your dependencies. Specifically, you can:
Install a tool or runtime on the fly (even on Microsoft-hosted agents) just in time for your CI build.
Validate your app or library against multiple versions of a dependency such as Node.js.
For example, you can set up your build pipeline to run and validate your app for multiple versions of Node.js.
Example: Test and validate your app on multiple versions of Node.js
Want a visual walkthrough? See our April 19 news release.
Create an azure-pipelines.yml file in your project's base directory with the following contents.
pool: vmImage: 'Ubuntu 16.04' steps: # Node install - task: NodeTool@0 displayName: Node install inputs: versionSpec: '6.x' # The version we're installing # Write the installed version to the command line - script: which node
Create a new build pipeline and run it. Observe how the build is run. The Node.js Tool Installer downloads the Node.js version if it is not already on the agent. The Command Line script logs the location of the Node.js version on disk.
Tool installer tasks
For a list of our tool installer tasks, see Tool installer tasks.
Help and support
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.