Friday, May 7, 2021

Build your Azure DevOps extensions with Azure Pipelines

In this blog I will be discussing about building azuredevops extension using an azure pipeline.

Whenever we lack some out of the box functionality in ADO, we might need to develop an ADO extension and deploy them using CI-CD. 

In order to build and deploy them we have some useful extension available in marketplace. These extension tasks helps in smoothly building and deploying an extension. They are:
  1. Azure DevOps Extension Tasks : This extension helps in building and publishing your extension. This is developed my Microsoft DevLabs
  2. Version Number Counter : This task helps in incrementing the version number of the extension. 
Create your build pipeline:

1.Use the classic editor pipeline and select your repository:


















2.For building the extension I am going to use the below tasks:
























  • Use Node CLI for ADO(tfx-cli) : This will download and install the Node CLI for Azure Devops

















  • Version Number Counter: This is used to automatically update the version number. This extension will increment the minor of build version for each build execution. In this task we have mention couple of variable: version and PAT. Version should be in x.x.x  format and PAT should be your ADO pat. Here I have provided version as 1.0.0 with variable name as version itself and variable name for Pat is PAT



















Variables can be added under variable section inside the pipeline as shown below:






  • Package Extension: This will build and package the extension to VSIX format.
Here the first thing that we need to provide is manifest root folder. Since my manifest file is inside $(Build.SourcesDirectory), I have provided the same. For other it could be $(Build.SourcesDirectory)\some folder name\home as well.Next thing to provide is publisher name and extension version. Publisher name should be the name of the publisher who is publishing the extension and version can be provided as the same variable that was provided earlier as $(version).


































  • Copy files: This task can be used to copy the output's to the artifact's folder





















  • Publish Artifact : This task is used to publish the artifact to the Build Pipeline





















Once you run the pipeline successfully, you can see the build artifacts .vsix as the inside the build artifacts:






Now you can publish this artifact to market place using another build tasks using release pipeline or extending the same pipeline, about which I will be covering in my next blog. Manual way to publish this would be download the .vsix from the artifact and manually upload and publish it to the market place.

Reference: