Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Objective

The goal of the tutorial is to demonstrate on how to initiate an Azure DevOps Build pipeline. Post trigger, it will check for Build pipeline completion status as well.

We will walk through each of the FlexDeploy features that will be created and configured to accomplish this goal. By following the steps below, we will be able to Build the Pipeline in Azure DevOps in a very short amount of time.

Checklist

...

Checklist

...

Description

...

Mandatory

...

Azure DevOps Organization URL

...

The Organization URL of the Azure DevOps.

...

Yes

...

Azure DevOps Personal Access Token

...

The Personal Access Token to connect to Azure DevOps.

...

Yes

...

Build Definition Id

...

The ID of the Build Definition.

...

Yes

...

Project Name

...

The Name of the Project.

...

Yes

...

Package Name

...

The Name of the Package to be published to Azure DevOps Artifacts Source

...

Yes

...

API Version

...

The API version of the Azure DevOps REST API. Defaults to 7.0.

...

Yes

...

Feed Name

...

The Name or ID of the Feed.

...

Package Version

...

The Version of the Package to download the Artifact from Artifacts Source. – is it correct?

...

Queue Id

...

The Queue ID of the pool that will be used to queue the build.

...

Commit Id

...

The Commit ID of the branch to build.

...

Branch Name

...

The Name of the Branch to build.

...

Additional Parameters

...

Provide Artifacts Metadata JSON payload.

...

Variables List

...

Provide double hash (##) separated variable key-value pairs of variable-group. e.g. var1:value1##var2:value2

...

Package Path

...

Absolute directory path to place the artifacts. If not specified, then it will place the files in the FD_ARTIFACTS_DIR.

Pre-requisite

There are pre-requisite permissions that needs to be included inorder to publish any Artifacts to the Azure DevOps Artifacts Source. Especially, The user must have the ‘<Project Name> Build Service’ permission to publish the Universal Packages.

Step-i) Navigate to the Feed Settings

  • Make sure you are in correct Project. Click on the Artifacts and select the feed from the dropdown to give the permissions. Then click on the Feed settings (gear icon).

...

Step-ii) Navigate to the Permissions tab.

  • Click on the Add users/groups button

...

Step-iii) Add the Permissions

  • Select the <Project Name> Build Service user/group from the drop-down and set the role as contributor (contributor will have both read and write access).

...

YAML Script

To update the Yaml script, follow the below steps:

  1. Click on the Pipelines to navigate to the Pipeline Definition ( yaml script )

    Image Removed
  2. Create the variables $packageName , $packageVersion under pipeline definition

    1. Click on the variables button

      Image Removed

    2. Click on the new variables button.

      Image Removed

    3. Update the values

      1. Name of the variable

      2. Value of the variable : Skipping this value as we are passing that value in Flexdeploy

      3. Make sure to check the ‘Let users override this value when running this pipeline’ checkbox

        Image Removed

    4. Create another variable for $packageVersion by clicking on the '+' icon

      Image Removed
    5. Similarly, update the name ( packageVersion ) and check on the ‘Let users override this value when running this pipeline’ checkbox.

  3. Now, on the right-hand pane, on the search box filter for Universal Package.

    Image Removed

  4. Click on the Universal Package to add the task to the existing Yaml script.

    Image Removed
    1. Command - Select the publish from the dropdown.

    2. Destination Directory - The directory location where the artifacts are generated by the Pipeline Execution.

    3. Feed - The Name of the Feed.

    4. Package Name - The Name of the Package.

    5. Version - The Version of the package to be published.

  5. Click on add. The below screenshot shows how the universal package job is added to the yaml script.

    Image Removed
  6. Now, updating the universal package code snippet based on your requirement and Click on the Save button to save the yaml script. Its highlighted as 1-5 , then there should be some explanation… add the script(only universal package) here as code snippet.

Sample Code Snippet:

Code Block
- task: UniversalPackages@0
  inputs:
    command: 'publish'
    publishDirectory: '$(System.DefaultWorkingDirectory)/build/jar/ant-sample.jar'
    feedsToUsePublish: 'internal'
    vstsFeedPublish: 'helloWorld/AzureFeedTest'
    vstsFeedPackagePublish: '$(packageName)'
    versionOption: 'custom'
    versionPublish: '$(packageVersion)'

Configure Cloud Account

...

  1. Select Integrations from the Menu.

  2. Navigate to the Cloud tab from the left-hand pane.

  3. Create a new Cloud account of the provider type “AzureDevOps” with the “+ Create” button.

...

It should have a Organization URL and Personal Access Token configured in it.

  1. Azure DevOps Access Token is a password (Personal Access Token) field and hence needs to be kept hidden. To update the same click on the pencil icon as shown below

  2. Update the Personal Access Token value under Secret Text. This is to make sure no one else can retrieve the password

...

Build Workflow

Navigate to the Workflows tab and create a workflow using the “+”(Click to create new Workflow) button

...

Next, create one Build workflow as shown below. The Workflow Type field defines the type of workflow.

Build Workflow

  1. Navigate to the Workflows tab

  2. Select the “+” button from the left-hand pane to create a new workflow with type as Build.

...

The Workflow Group and Subgroup define the folder hierarchy. Once the workflow is created, it should look like the below. No constraint on workflow or folder naming convention.

...

The steps of the workflow execution can be configured through the Definition section.

...

Below given is a sample build workflow to trigger the Pipeline Build and download the artifacts generated from Azure DevOps Artifacts Source to FlexDeploy Artifacts Directory.

You are saying download but mentioning publishArtifacts..they are just the opposite

...

Step-i: Build Pipeline

This step will trigger the Pipeline Build. As we configured the Universal Publish step in the yaml script in Azure DevOps, this workflow will publish the package Name and package version that we provided in the Azure DevOps Artifacts Source.

Again highlighted from 1-9 ..without any explanation

How exactly Branch is fitting here? You are not using in your build pipeline…also you are downloading from Git..

You can remove non essential parameter’s from checklist

...

Download artifact section missing

Build Workflow Properties

We'll start by creating a Workflow Property for the Feed Name, Package Name and Project Name.

  1. Go back to the Main tab of the Workflow

  2. Under Workflow Properties, choose open the Add men.

  3. From the Add menu, we can add an existing property, or create a new one. Select New Property

  4. Properties must each have a unique code, give a meaningful code for the new property

  5. A property display name does not have to be unique and can contain spaces. This is the name that will be displayed on the Target screen

  6. Select the property scope, this defines where the property will be configured. We're using Project because this property can be overridden at project level

...

Step-ii: Download the Artifacts from Azure DevOps Artifacts Source

Below given is the Azure plugin(downloadArtifacts operation) configurations.

...

Table of Contents

Objective

The goal of the tutorial is to demonstrate on how to integrate Azure DevOps Build pipeline through FlexDeploy.

  • FlexDeploy shall pass package and other relevant details to Azure DevOps Build pipeline and initiate the Build pipeline execution.

  • It can optionally pass build variable details as well.

  • it will check for Build pipeline completion status as well for a pre-defined number of times at regular interval.

  • The Build Pipeline shall store the generated package in Azure DevOps Artifact feed.

  • FlexDeploy will download the package and store as its own artifact, which can further be leveraged in FlexDeploy deploy flow.

We will walk through each of the FlexDeploy features that will be created and configured to accomplish this goal. By following the steps below, we will be able to Build the Pipeline in Azure DevOps in a very short amount of time.

Checklist

Checklist

Description

Mandatory

Azure DevOps Organization URL

The Organization URL of the Azure DevOps.

Yes

Azure DevOps Personal Access Token

The Personal Access Token to connect to Azure DevOps.

Yes

Project Name

The Name of the Azure DevOps Project.

Yes

Build Definition Name

The ID of the Azure DevOps Build Definition Name.

Yes

Package Name

The Name of the Package to be published to Azure DevOps Artifacts Source

Yes

API Version

The API version of the Azure DevOps REST API. Defaults to 7.0.

No

Feed Name

The Name or ID of the Azure DevOps Artifacts Feed.

Yes

Package Version

The Package version to be stored with in Azure Artifacts.

Yes

Variables List

Provide double hash (##) separated variable key-value pairs of variable-group. e.g. var1:value1##var2:value2

No

Package Path

Absolute directory path to place the artifacts. If not specified, then it will place the files in the FD_ARTIFACTS_DIR variable path.

No

Provide permission to interact with Artifacts (Pre-requisite)

There are pre-requisite permissions that needs to be included in order to publish any Artifacts to the Azure DevOps Artifacts Source. Especially, the Azure DevOps Build service must have the ‘contributor’ permission to publish the Universal Packages. This basically ensured the Build pipeline can interact with Azure DevOps Artifact. Below given are the steps,

  1. Navigate to Azure DevOps Project and click on the Artifacts.

  2. Select the feed from the dropdown to give the permissions.

  3. Next, click on the Feed settings (gear icon) as shown below.

...

  1. Navigate to the Permissions tab.

  2. Click on the Add users/groups button.

...

  1. Select the <Project Name> Build Service from the user/group drop-down and set the role as contributor (contributor will have both read and write access).

...

Update Azure DevOps Build pipeline

Our Build pipeline downloads the code from the Git Codebase and uses ant plugin to create a jar file. We want to publish the created artifact to Azure Artifact.

To update the Build pipeline YAML script, follow the below steps:

  1. Click on the Pipelines to navigate to the Pipeline Definition

  2. Select the desired Build Pipeline and select Edit option as shown below.

    Image Added

Next, we shall create the variables $packageName , $packageVersion under pipeline definition.

  1. Click on the variables button under Build Pipeline.

...

  1. Click on the new variables button.

...

  1. Provide the Variable Name. Value of the variable can be skipped as we are going to pass that value through FlexDeploy

  2. Make sure to check the ‘Let users override this value when running this pipeline’ checkbox. This will let FlexDeploy pass the argument value runtime.

...

Create another variable for $packageVersion by clicking on the '+' icon. As mentioned in previous step create the variable with name ( packageVersion ) and check on the ‘Let users override this value when running this pipeline’ checkbox.

...

Next, we shall use Universal Package task to publish the generated artifact to Azure Artifacts feed.

  1. On the right-hand pane, on the search box filter for Universal Package.

  2. Click on the Universal Package to add the task to the existing YAML script.

...

Next, we shall configure the Universal package task.

  1. Command - Select the Publish operation from the dropdown.

  2. Destination Directory - The directory location where the artifacts are generated by the Pipeline Execution Ant task (previous step).

  3. Feed - The Name of the Azure DevOps Artifact Feed.

  4. Package Name - The Name of the Package that will be published to the Feed.

  5. Version - The Version of the package to be published. We shall mark this value as custom, since we are going to update this dynamically.

  6. Click on add. The below screenshot shows how the universal package job is added to the YAML script.

...

Once Added the UniversalPackage task will be added in the pipeline.

...

Now, updating the universal package code snippet based on our requirement .We have added the packageName & packageVersion variable against the Feed Package name and corresponding version. We are going to pass these values through FlexDeploy.

...

Sample Code Snippet:

Code Block
languagenone
- task: UniversalPackages@0
  inputs:
    command: 'publish'
    publishDirectory: '$(System.DefaultWorkingDirectory)/build/jar/ant-sample.jar'
    feedsToUsePublish: 'internal'
    vstsFeedPublish: 'helloWorld/AzureFeedTest'
    vstsFeedPackagePublish: '$(packageName)'
    versionOption: 'custom'
    versionPublish: '$(packageVersion)'

Configure Cloud Account

First, an Azure DevOpsaccount needs to be configured under Integrations. FlexDeploy will use this account to integrate with Azure DevOps.

  1. Select Integrations from the Menu.

  2. Navigate to the Cloud tab from the left-hand pane.

  3. Create a new Cloud account of the provider type “AzureDevOps” with the “+ Create” button.

...

It should have an Organization URL and Personal Access Token configured in it.

  1. Azure DevOps Access Token is a password (Personal Access Token) field and hence needs to be kept hidden. Create a new credential named Azure DevOps access token.

  2. Update the Personal Access Token value under Secret Text. This is to make sure no one else can retrieve the password. Ref on how to generate PAT in Azure DevOps: https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows#create-a-pat

  3. Click in Save.

...

Build Workflow

Navigate to the Workflows tab and create a Build workflow using the “+”(Click to create new Workflow) button. The Workflow Type field defines the type of workflow.

Build Workflow

  1. Navigate to the Workflows tab

  2. Select the “+” button from the left-hand pane to create a new workflow with type as Build.

...

The Workflow Group and Subgroup define the folder hierarchy. Once the workflow is created, it should look like the below. No constraint on workflow or folder naming convention.

...

The steps of the workflow execution can be configured through the Definition section.

  1. Navigate through the plugin operations and find the desired one.

  2. In our workflow execution, 2 plugin operations being used to achieve our goal.

...

Below given is the detailed explanation of our workflow operations.

...

Build Workflow Properties

We'll start by creating a Workflow Property for the Feed Name, Package Name, Package Version, Project Name, Build Definition Name and Variables List.

  1. Go back to the Main tab of the Workflow

  2. Under Workflow Properties, use Add option to add the properties.

  3. From the Add menu, we can add an existing property, or create a new one. Select New Property

  4. Properties must each have a unique code, give a meaningful code for the new property.

  5. A property Display Name does not have to be unique and can contain spaces. This is the name that will be displayed on the properties association screen.

  6. Select the property scope, this defines where the property will be configured. We're using Project because this property can be overridden at project level.

n.b. The properties scope can be Target as well. In case any property value is environment specific (e.g. Project Name is different for each environment), then the scope should be set as Target. This will changes based on requirement.

...

We are using multiple Project properties, not all of them are mandatory.

Build Pipeline operation

This step will trigger the Pipeline Build. As we configured the Universal Publish step in the YAML script in Azure DevOps, this workflow will publish the package Name and package version that we provided in the Azure DevOps Artifacts Source.

We are passing some relevant project properties against the workflow input. The arguments can change based on different requirements.

...

Build Pipeline Input details

Input Name

Mandatory

Description

Build Definition Id

No

The Name of the definition to queue.

Build Definition Name

No

The Id of the definition to queue. (Provide Either the Definition Id or Definition Name as input.)

Queue Id

No

The Queue Id of the pool that will be used to queue the build.

Commit Id

No

The Commit ID of the branch to build.

Branch Name

No

The Name of the Branch to build. Required if there is not a default branch set up on the definition

Variables List

No

Provide double hash (##) separator variable key-value pairs of variable-group.( e.g. var1:value1##var2:value2. )

Project Name

Yes

The Name of the Project.

Package Name

Yes

The Name of the package.

Additional Parameters

No

Add any additional parameters not listed above, which will be appended to the Build Pipeline CLI Command. (e.g. --debug, --query etc. )

Download the Artifacts from Azure DevOps Artifacts Source

Below given are the Azure plugin (downloadArtifacts operation) configurations. Some relevant details are provided so that FlexDeploy can download the generated package version from previous step and save it as an artifact.

...

Download Artifacts Inputs

Input Name

Mandatory

Description

Feed Name

Yes

The Name of the Feed.

Package Name

Yes

The Name of the Package.

Project Name

Yes

The Name of the Project.

Package Version

No

The Version of the package.

Package Path

No

Absolute directory path to place the artifacts. If not specified, then it will place the files in the FD_ARTIFACTS_DIR.

Additional Parameters

No

Add any additional parameters not listed above, which will be concatenated to the download artifacts command.

Click on save and Activate the workflow.

...

Provide the value for AzureDevOpsCloudAccount, AzureCLIPath (optional if set in classPath), Azure DevOps API Version (optional default value is 7.0), Scope of the Feed (optional default value is project used in publish artifacts operation), Number of Iterations (optional, default value is 6), and, Interval Duration (optional default value is 30sec) and map the localhost (FlexDeploy Server) as Endpoint as shown below. Also, the target level properties that we created at the workflow level will be displayed here along with other properties.

...

Property Name

Mandatory

Values for this Tutorial

Description

Azure DevOps Cloud Account

Yes

AZDEVOPSINDAZDevOpsIND

The Azure Cloud Account Name configured.

Absolute path of Azure CLI

Optional

 

The path to the directory where Azure CLI is installed. (Optional)
eg: /u01/azure/bin

Number of Iterations

Optional (default is 6)

6

The number of iterations to perform the status check.

Interval between release status check

Optional (default is 30)

30

The interval between Azure VM status check.

Azure DevOps API Version

Optional (default is 7.0)

7.0

The API Version of the Azure DevOps REST.

Server Config File Port

Yes

8054

The Port of the Azure Server Config File.

Az Storage Blob Container Name

Yes

dev-container

The Name of the Azure Blob Container.

Scope of the Feed

Optional

Project

Scope is “project”, if the feed was created in a project otherwise “organization”.

...

The screen displays the list of blueprints supported by the FlexDeploy. Select a Blank project from the list or you can search for the blueprint in the search filter present in the top.

...

General Configuration

Scroll through this guide to fill in the project information.

...

Property Name

Mandatory

Value for this tutorial

Description

Project Name

Yes

Azure DevOps Build Flow

The Name of the Project.

Folder

Yes

FlexDeploy / Azure DevopsDevOps

This is the Folder path where the Project resides.

Description

Optional

 

Brief description of the project.

Project Classification

Yes

Standard

The classification of the project.

...

  1. To configure Project specific settings one can navigate to the Project Configuration tab as shown above.

  2. Next, select the PROPERTIES option from the left-hand pane.

  3. Click on Save.

...

Property Name

Mandatory

Value for this tutorial

Description

Branch Name

Optional

The Name of the Branch to build.

Definition Name

Optional

The Name of the Pipeline Definition.

Note :Provide Either Definition Id or Definition Name to trigger the build.

Feed Name

Yes

 AzureFeedTestAzureFeedTest

The Name of the Feed.

Package Name

Yes

demo-package

The Name of the Package.

Project Name

Yes

helloWorld

The Name of the Project.

Build Definition Id

Yes

4

The ID of the Build Pipeline Definition.

Note: Provide Either Definition Id or Definition Name to trigger the build.

Package Version

Yes

FD_PROJECT_VERSION

The Version of the Package to be published and downloaded to.

Create Release Variables List

Optional

Provide JSON payload or double-hash (##) separated list of variables to Create the Release.

...

Post Deployment success might take some time to deploy the package with provided version. In case of failure we can easily debug the issue from the log or navigate to the Web URL which is returned as output variable FDAZ_DEVOPSDevOps_OUT_BUILD_PIPELINE_WEB_URL in Azure DevOps Platform.

...