Create Task Group Azure DevOps with Custom Parameters and Scopes

Author

Posted Oct 25, 2024

Reads 619

Blurred Blue Design
Credit: pexels.com, Blurred Blue Design

Creating a task group in Azure DevOps is a powerful way to streamline your workflow, and with custom parameters and scopes, you can tailor it to your specific needs.

To create a task group with custom parameters, you can define them in the task group's YAML definition. This allows you to pass values to the tasks within the group.

By using custom parameters, you can make your task group more flexible and adaptable to different scenarios. This is especially useful when working with variable environments or testing different configurations.

You can also scope your task group to specific projects or teams, giving you more control over where and how it's used.

Readers also liked: Azure Create Custom Role

Azure DevOps Basics

Azure DevOps is a cloud service that supports pipeline as code, allowing users to store the pipeline definition in version control.

It includes many DevOps orchestration services, such as Azure Boards to track a software project and Pipelines to build, test and share code.

Credit: youtube.com, Azure DevOps Tutorial for Beginners | CI/CD with Azure Pipelines

A stage is one or more jobs for a logical phase of the CI/CD process, and admins can create stages for build, test and release, for example.

Jobs are the units of work that get assigned to an agent, and a job is a list of sequential steps to perform on an agent.

Steps are the atomic unit of work, and a step can be a task, script or reference to a template.

The environment is a collection of resources, such as VMs, that the deployment targets.

Here's a breakdown of the key components:

  • Stage: one or more jobs for a logical phase of the CI/CD process
  • Job: units of work assigned to an agent
  • Step: atomic unit of work, can be a task, script or reference to a template
  • Environment: collection of resources, such as VMs, that the deployment targets

Azure DevOps Basics

Azure DevOps is not tied to one language, platform, or cloud, and it includes many DevOps orchestration services.

Azure Pipelines is a cloud service that supports pipeline as code, allowing users to store the pipeline definition in version control. This means you can manage your pipeline definitions alongside your code.

A stage is one or more jobs for a logical phase of the CI/CD process, and admins can create stages for build, test, and release, for example. Stages help organize the pipeline into manageable chunks.

Discover more: Storage in Azure Cloud

Credit: youtube.com, Azure DevOps Tutorial for Beginners | CI/CD with Azure Pipelines

Jobs are the units of work that get assigned to an agent, and a job is a list of sequential steps to perform on an agent. The deployment job is a special set of steps run against the environment to deploy.

Steps are the atomic unit of work, and a step can be a task, script, or reference to a template. Steps are the building blocks of a job.

Here's a breakdown of the pipeline components:

  • Stage: one or more jobs for a logical phase of the CI/CD process
  • Job: the units of work that get assigned to an agent
  • Step: the atomic unit of work, can be a task, script, or reference to a template

The IT organization controls Azure Pipelines through both manual and programmatic means. This includes approvals, triggers, variables, templates, and artifacts.

Definitions

In Azure DevOps, a JSON object is represented by the JObject class. This is useful for storing and retrieving data in a structured format.

A JToken is an abstract JSON token that can be used to represent various types of data, such as strings, numbers, and booleans.

You can use the ReferenceLinks class to represent a collection of REST reference links, which is helpful for navigating and accessing related resources.

If this caught your attention, see: Create Azure Data Lake Storage Gen2

Credit: youtube.com, DevOps In 5 Minutes | What Is DevOps?| DevOps Explained | DevOps Tutorial For Beginners |Simplilearn

Azure DevOps also provides a TaskGroupDefinition, which represents tasks in a task group. This includes properties like displayName, isExpanded, name, tags, and visibleRule.

Here's a breakdown of the TaskGroupDefinition properties:

Note that the TaskGroupDefinition properties can be used to customize and manage task groups in Azure DevOps.

A TaskDefinitionReference represents a reference to a task definition, which includes properties like definitionType, id, and versionSpec. These properties can be used to identify and access task definitions in Azure DevOps.

Expand your knowledge: Azure Devops Create New Area

Task Group Creation

To create a task group in Azure DevOps, you need to open the pipeline where you want to create the new task group.

First, select Unlink all in the pipeline settings panel, and then select Confirm to ensure that none of the tasks you intend to include contain any linked parameters.

Next, select a sequence of pipeline tasks that you want to turn into a task group, right-click to open the context menu, and then choose Create task group.

Credit: youtube.com, Azure Pipelines Tutorial: How to Create Task Groups and Add Tasks for Seamless CI/CD!

Specify a name and description for the new task group, and the category in the Add tasks pane you want to add it to.

The new task group is created and replaces the selected tasks in your pipeline, with all the '$(vars)' from the underlying tasks, except predefined variables, surfacing as the mandatory parameters for the newly created task group.

You can edit the values of these parameters if necessary.

To save your updated pipeline, select Save after creating the task group.

For another approach, see: Azure Create New App Service

Task Group Management

Task Group Management is a crucial aspect of creating task groups in Azure DevOps. You can import previously saved task group definitions from the top of the Task groups page, allowing you to transfer task groups between projects and enterprises.

To manage a task group, you can right-click or select the More actions icon for the group, and select one of the following options: Delete, Export, or Security. Deleting a task group requires a confirmation screen.

You can also export a task group as a JSON pipeline. To do this, select Export from the context menu. This feature is useful for replicating and saving copies of your task groups.

Manage

Credit: youtube.com, How To Delegate Tasks Like a Pro: Team Task Management Tips

Managing task groups is a crucial part of pipeline management. You can import previously saved task group definitions from the top of the Task groups page.

To manage a task group, right-click or select the More actions icon for the group, and select one of the following options from the context menu: Delete, Export, or Security.

Deleting a task group is a straightforward process. Select Delete to delete the task group, and then select Delete again on the confirmation screen.

You can also export a task group as a JSON pipeline by selecting Export. This feature is useful for replicating and saving copies of your task groups.

To define who can use, edit, delete, or set permissions for a task group, select Security from the context menu. This feature is available at both the task group and project levels.

To edit a task group, select the task group name on the Task groups page. This will open the task group details page for editing.

Return

Credit: youtube.com, How to Manage Your Personal & Team Tasks with Todoist Team Workspaces

Return is a crucial aspect of Task Group Management, and understanding how it works can make a big difference in your workflow. You can set a task group as deleted by setting the deleted field to true.

The deleted field is a boolean value that indicates whether the task group is deleted or not. It's a simple way to mark a task group as no longer usable.

Here are some key points to keep in mind when working with the deleted field:

  • Setting the deleted field to true will mark the task group as deleted.
  • The deleted field is a boolean value, which means it can only be true or false.
  • Deleting a task group does not delete its associated data, but rather marks it as no longer usable.

By understanding how return works in Task Group Management, you can better manage your tasks and keep your workflow organized.

Task Group Deployment

In the Deploy stage, a job and multiple steps work together to deploy changes to infrastructure. This stage relies on the DeployJob job, which includes steps to build and configure Pulumi.

The Deploy stage uses manual approvals to ensure that team members review and approve the changes before deployment. The final task runs a command to generate a preview of the changes, allowing team members to assess the impact of the change.

Credit: youtube.com, How to create a Task group for reusability

Here are the key steps in the Deploy stage:

  • Template reference to build/downloadArtifact.yml
  • Template reference to build/configurePulumi.yml
  • Run a command to generate a preview of the changes

With these steps, the Deploy stage can automatically deploy the last successful release to new target servers. This is especially useful when new target servers are added to a deployment group.

Deploy Stage

The Deploy stage is the final part of the DevOps pipeline, relying on the Azure DevOps environment and manual approvals.

This stage defines a job with multiple steps, which are identical to those in the Preview stage, as explained in the previous steps. The job is called DeployJob.

The Deploy stage uses template references to build/downloadArtifact.yml and build/configurePulumi.yml, which are the same steps used in the Preview stage.

The final task in this stage runs a command to generate a preview of the changes to be deployed to the infrastructure, allowing team members to review the impact of the change.

Once approved, the previewed changes are deployed, as shown in Figure 9. This manual approval process ensures that the changes are thoroughly reviewed before deployment.

Here are the key steps in the Deploy stage:

  1. Template reference to build/downloadArtifact.yml
  2. Template reference to build/configurePulumi.yml
  3. Final task to generate a preview of the changes

These steps work together to ensure a smooth and controlled deployment process, giving team members the confidence to deploy changes to the infrastructure.

Automatically Deploy to New Servers

Credit: youtube.com, Task Groups in Azure Pipelines with Parameters

You can configure your environment to automatically deploy the last successful release to new target servers.

To set this up, select the post deployment icon in your release pipeline definition.

On the Post-deployment conditions screen, enable the Auto redeploy trigger.

Select New target with required tags becomes available under Select events.

Redeploy the last successful deployment on this environment under Select action.

Task Group Configuration

As you create a task group in Azure DevOps, you'll want to configure it to your liking. To do this, you can extract task parameters as variables, which will automatically convert used variables into parameters for the task group.

You can define parameters as variables, such as $(MyVariable), and these will be exposed as configurable parameters in the task group. Any task parameters without values or with specified values instead of variables will become fixed parameters.

To configure the task group, you'll need to provide a name, description, and friendly name, as well as set the author, category, and icon URL. You'll also need to define the input for the task group and specify the display name and parent task group ID.

Credit: youtube.com, What is a task group in Azure DevOps? | How to create Task Groups and Integrate with CI/CD pipelines

Here are the required fields for task group configuration:

These fields are essential for creating a task group in Azure DevOps.

Minor Version Update

Minor version updates are a great way to make small changes to your task group without affecting the version number.

You can create a minor version update by directly saving the task group after editing it instead of saving it as a draft. This will keep the version number the same, but the latest changes will show up in the pipeline definition automatically.

For example, if your task group is version 1, you can have any number of minor version updates such as 1.1, 1.2, and 1.3. In your pipeline, the task group version will show as 1.*.

Use minor version updates for small changes in the task group, when you expect pipelines to use the new change without changing the version number in the pipeline definition.

Credit: youtube.com, Microsoft Project - Lesson 9 - Creating Sub Groups of Tasks

Here are some key things to keep in mind when creating a minor version update:

  • The version number doesn't change.
  • The latest changes show up in the pipeline definition automatically.
  • You can have any number of minor version updates, such as 1.1, 1.2, and 1.3.
  • The task group version shows as 1.* in the pipeline.

By following these guidelines, you can make small changes to your task group without affecting the version number, and keep your pipelines up to date with the latest changes.

Input Definition

In a task group, you can define input parameters using the TaskInputDefinition. This definition has several properties, including aliases, default value, group name, and help text.

The aliases property is an array of strings that represent alternative names for the input parameter. For example, if you have an input parameter named "MyParameter", you can define an alias for it as "MyParam".

The default value property is a string that represents the default value of the input parameter. This value will be used if no value is provided for the parameter.

The group name property is a string that represents the group name of the input parameter. This is useful if you have multiple input parameters that belong to the same group.

For another approach, see: Azure Storage Account Connection String

Credit: youtube.com, Executing Task Groups

The help text property is a string that represents the help text for the input parameter. This text will be displayed to the user when they are prompted to enter a value for the parameter.

Here are the properties of the TaskInputDefinition in a table:

The required property is a boolean that indicates whether the input parameter is required. If it is true, the user will be required to enter a value for the parameter.

The type property is a string that represents the type of the input parameter. This can be used to determine how the parameter should be validated and displayed to the user.

The validation property is an object of type TaskInputValidation that represents the validation rules for the input parameter. This can be used to specify custom validation rules for the parameter.

The visibleRule property is a string that represents the rule for determining whether the input parameter is visible. This can be used to control the visibility of the parameter based on certain conditions.

Ann Predovic

Lead Writer

Ann Predovic is a seasoned writer with a passion for crafting informative and engaging content. With a keen eye for detail and a knack for research, she has established herself as a go-to expert in various fields, including technology and software. Her writing career has taken her down a path of exploring complex topics, making them accessible to a broad audience.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.