Publishing build artifacts from Azure VSTS(DevOps) to OneDrive

Steps below will allow you to publish contents of your Azure VSTS (DevOps) Repo to Sharepoint online and by proxy to OneDrive as well.

There is no built-in task available in either build or release pipeline to push files to OneDrive so solution below relies on Azure Logic Apps to perform those functions.

Overall flow is below

  1. Azure DevOps completes build which packages code in ZIP file as build artifact
  2. Azure DevOps project calls Azure Logic App webhook 
  3. Azure Logic App retrieves results of build task and extracts to Sharepoint online documents folder

Steps in detail:

Create build pipeline in Azure Devops

Yaml file as well as UI representation is below. It packages files in scripts folder into ZIP file into subfolder called Powershell Scripts

chrome_2019-02-15_12-27-43


Create Azure LogicApp

Define a trigger of HTTP request type. Use following Request Body Schema. You can download schema from here https://gist.github.com/artisticcheese/2b5410ee65bc7b76273fdef47edd0c4b

Save trigger which will give you HTTP Post URL which you would need to use later in Azure DevOps project

Since you might have more then 1 build in your Azure Devops pipeline you need to have conditional logic in your LogicalApp to only publish on results of specific buildID.

Second step in LogicApp is “Condition” based on definition id number of your build. In my case it’s 5

Condition

Next steps are initialize 2 variable. First one will be holding buildID number as well authorization information for AzureDevops.

To create Authorization token you need to create PAT token in AzureDevops and encode :{token} into Base64. For example if my PAT token is a123 then go to https://www.base64encode.org/ and encode value of :a123 into OmExMjM=

Add Send an HTTP Request to Azure Devops as next step and modify parameters respectively for your values. Output of this step will allow to get URL to download artifact.

Add 2 steps to parse JSON and extract value of downloadURI. Schema can be download from here https://gist.github.com/artisticcheese/0cf1d9c4b35e9fe3d01ea408555c3d15

Last 3 steps are downloading artifact from URL and extracting it to Sharepoint site

Add webhook to AzureDevops

Go to project settings and add a service hook

Enter webhook URI you get in previous steps for LogicApp

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s