Freigeben über


Task groups for builds and releases (classic)

TFS 2017

Note

In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.

Note

Task groups are not supported in YAML pipelines. Instead, in that case you can use templates. See YAML schema reference.

A task group allows you to encapsulate a sequence of tasks, already defined in a build or a release pipeline, into a single reusable task that can be added to a build or release pipeline, just like any other task. You can choose to extract the parameters from the encapsulated tasks as configuration variables, and abstract the rest of the task information.

The new task group is automatically added to the task catalog, ready to be added to other release and build pipelines. Task groups are stored at the project level, and are not accessible outside the project scope.

Task groups are a way to standardize and centrally manage deployment steps for all your applications. When you include a task group in your definitions, and then make a change centrally to the task group, the change is automatically reflected in all the definitions that use the task group. There is no need to change each one individually.

Before you create a task group...

  • Ensure that all of the tasks you want to include in a task group have their parameters defined as variables, such as $(MyVariable), where you want to be able to configure these parameters when you use the task group. Variables used in the tasks are automatically extracted and converted into parameters for the task group. Values of these configuration variables will be converted into default values for the task group.

  • If you specify a value (instead of a variable) for a parameter, that value becomes a fixed parameter value and cannot be exposed as a parameter to the task group.

  • Parameters of the encapsulated tasks for which you specified a value (instead of a variable), or you didn't provide a value for, are not configurable in the task group when added to a build or release pipeline.

  • Task conditions (such as "Run this task only when a previous task has failed" for a PowerShell Script task) can be configured in a task group and these settings are persisted with the task group.

  • When you save the task group, you can provide a name and a description for the new task group, and select a category where you want it to appear in the Task catalog dialog. You can also change the default values for each of the parameters.

  • When you queue a build or a release, the encapsulated tasks are extracted and the values you entered for the task group parameters are applied to the tasks.

  • Changes you make to a task group are reflected in every instance of the task group.

Create a task group

  1. Ensure that all the tasks you intend to include do not contain any linked parameters. The easy way to do this is to choose Unlink all in the settings panel for the entire process.

    Unlinking parameters for all tasks

  2. Select a sequence of tasks in a build or release pipeline, open the shortcut menu, and then choose Create task group.

    Creating a task group from a release pipeline list of tasks

  3. Specify a name and description for the new task group, and the category (tab in the Add tasks panel) you want to add it to.

  4. After you choose Create, the new task group is created and replaces the selected tasks in your pipeline.

  5. All the '$(vars)' from the underlying tasks, excluding the predefined variables, will surface as the mandatory parameters for the newly created task group.

    For example, let's say you have a task input $(foobar), which you don't intend to parameterize. However, when you create a task group, the task input is converted into task group parameter 'foobar'. Now, you can provide the default value for the task group parameter 'foobar' as $(foobar). This ensures that at runtime, the expanded task gets the same input it's intended to.

  6. Save your updated pipeline.

Help and support