FlexDeploy integration with Azure DevOps Build Pipeline

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

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.

Next, we will create the variables $packageName and $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 can 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 will 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:

- 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 DevOps account 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: Use personal access tokens - Azure DevOps

  3. Click in Save.

Build Workflow

Navigate to Workflows and create a build workflow using the button as highlighted below.

Below are the steps of our workflow.

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 to the Properties tab of the Workflow

  2. We can add an existing property or create a new one. Select Create

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

  4. 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.

  5. 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.

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 change based on requirements.

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

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

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.

Topology

For detailed steps on how to configure the topology and target properties, please refer to Target Groups

Target Properties

Selecting the DEV environment mapped to the Target Group will display the configurable properties/Endpoint and allows to the configure the properties.

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.

Target Properties Info

Property Name

Mandatory

Values for this Tutorial

Description

Property Name

Mandatory

Values for this Tutorial

Description

Azure DevOps Cloud Account

Yes

AZDevOpsIND

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”.

Create the Azure DevOps Build Pipeline Flow Project using Blank Project

The assumption is that you have FlexDeploy installed and ready for use. When logged into the FlexDeploy, you will see the Home page. Click on the + icon on the top and click “Create Project” to create a new project.

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.

Project Info

Property Name

Mandatory

Value for this tutorial

Description

Property Name

Mandatory

Value for this tutorial

Description

Project Name

Yes

Azure DevOps Build Flow

The Name of the Project.

Folder

Yes

FlexDeploy / Azure DevOps

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.

Project configuration

We can see the Folder hierarchy on the top of the project and the project configuration as below

Here, we are giving the empty deployment. You can refer to Azure DevOps Create Release Flow and use this build workflow and perform an End-to-End Build and Release Flow in Azure DevOps.

Project Properties

  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.

  1.  

Property Name

Mandatory

Value for this tutorial

Description

Property Name

Mandatory

Value for this tutorial

Description

Definition Name

Optional

 

The Name of the Pipeline Definition.

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

Feed Name

Yes

AzureFeedTest

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.

Build Execution

Navigate to Execution tab and click on Execute to submit the Build Request form.

The Build Request Form will appear and we need to:

  1. select the environment we want to generate and publish the Artifacts.

  2. submit the request, this will initiate the AzureDevOpsBuildFlow workflow.

Upon submission, the build workflow is initiated and the workflow steps are executed on the AzureInstance target group in the DEV environment, utilizing the Localhost endpoint to generate the Artifacts and publish Artifacts using buildPipeline operation and downloadArtifacts will download the generated artifacts based on the package Name and package Version from the Azure DevOps Artifacts Source to the FlexDeploy Artifacts Directory, if package path is given as empty . Upon completion of the workflow, the execution status will be successful.

Navigate to steps tab in order to view the workflow steps. Click on the link to view the plugin logs.

Reports

With the successful execution of the Build workflow, a text (.txt) file is created, stored in the reports tab. Every execution will generate a new report with execution Id appended to the text file in the Reports tab.

Click on the text file generated to see the details. This file captures the details of each instance i.e., Pipeline Definition Name, Pipeline Definition Id, Pipeline Build Status and Pipeline Build Result. User can download the report file generated.

Post deployment - Build Pipeline Execution on Azure DevOps

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_DevOps_OUT_BUILD_PIPELINE_WEB_URL in Azure DevOps Platform.

Azure DevOps Build Pipeline Logs

Navigate to the link that is returned as output variable in the above screenshot. Now, click on Job and check the Universal Packages step. We can see that the package named demo-package with version 1.0.4 is publishing.

Azure DevOps Artifacts Source

Navigate to Artifacts Source as shown below. We can see that the demo-package with version details is published to the Artifacts Source in Azure DevOps.

Congratulations! You have successfully completed the Azure DevOps Build Pipeline tutorial.

Now that you have configured FlexDeploy for one Azure DevOps Pipeline Build Flow, it is extremely easy to replicate the same for other Pipeline Flow. Simply use the Copy Project feature and a new project will be created with all of the configuration completed already. You just need to make the necessary configuration changes.

 

The following macros are not currently supported in the footer:
  • style