SharePoint Online Continuous Delivery with Visual Studio Team Services (part 3)

Link to part 1/3: https://sharepointologic.blogspot.fr/2017/01/sharepoint-online-continuous-delivery_17.html
Link to part 2/3: https://sharepointologic.blogspot.fr/2017/02/sharepoint-online-continuous-delivery.html
In this post I'll focus on how to configure Visual Studio Team Services to enable automatic deployment.

Now that source code and deployment agent are ready (see post 1 & 2) we can proceed  configuring the deploy pipeline.

Making the Build Definition

First you need to create a Build Definition in order to create an Artefact with your source code. Go ahead and go to "Build & Release > Builds".
image

Select create a new build definition and just select the "Visual Studio" template and hit Next.
image

You should get to this:
image

To make it simple just remove tasks for : NuGet, Buil solution, Test and Publish. You should be left with the following:
image

Edit the "Copy Files" task and set Contents to "**" to select all files.
image

Then go to "Options" and select "Default" in the "Default agent queue" menu. This will make the job run on our custom Agent (see blog post 2/3)
image

Then click "Save & queue"
image

Agent queue should be on "Default", then click "Queue"
image

Build should complete and source copied in the Artefact:
image

You can check the content of the Artefact using the dedicated tab after build success:
image

Make Release Definition

Now that the Artefact is generated we can make the Release Definition that will handle deployment to target environments.
Go to the Release Tab and click "+ New Definition"
image

Select the "Empty" template
image

Select the Build Definition created previously. If you need to automate deployment process to start after build check "Continuous deployment" else you can change this setting later.
image

You will be brought to this screen
image

Click "Run on agent" link
image

And set Deploymnent queue to "Default" (to select our custom agent)
image

Then click "Add tasks" and select "PowerShell" under "Utility"
image

For script path select the "prov.ps1" file from the sources:
image

Then with the environment menu select "Configure variables…"
image

If you remind post 1 we had prepared these lines in the script:
# Get site url
set-variable -scope Global -name siteUrl -value $env:siteUrl

# Get credentials
$password = $env:deploypassword | ConvertTo-SecureString -asPlainText -Force
$username = $env:deployusername
$cred = New-Object System.Management.Automation.PSCredential($username,$password)

So add variables accordingly and click OK:
image

Then with the environment menu Clone as much as needed
image

You should end with this:
image

The last step required is setting up variables for each environment. Go to "Variables" tab then select "Environment variables"
image

Complete UAT and PRD values. This is what enables using the same "prov.ps1" script for multiple environments:
image

Now save the definition and test it with "Create Release"
image

From here you should have a functional basic deployment pipeline for your SharePoint Online Sites and you can start playing DevOps style Smile
image

Comments