Automated Deployments with Sitecore Content Serialization in Azure DevOps

In this post, I will be demonstrating how you can build the Sitecore Item Package during the build and install the package in the release pipeline. This scenario is for an on-premise VM deployment however, this will work for other scenarios as well.

Configuring the Azure DevOps build pipeline

Add a task to your agent job. This should be a Powershell task.

In the powershell task, select the “Inline” type and add in the follow code to the “Script” field. Replace <package name> with your [name.itempackage].

dotnet new tool-manifest
dotnet tool install Sitecore.CLI --add-source https://sitecore.myget.org/F/sc-packages/api/v3/index.json
dotnet sitecore ser pkg create -o <package name>

When the agent runs the job, Sitecore.CLI will be installed in the Agents working directory. Once that occurs, you can call Sitecore.CLI commands via powershell.

The Powershell task will list all the items that it will include in the package.

A summary is provided when the task is complete.

Finally, you will need to publish the package as a build artifact. Add a task to the Agent that is the the type of “Publish build artifacts”. Here is the configuration for this task. The path to publish is the name of the item package.

When the build completes, the artifact looks like this.

Configure a non-interactive client login on the CM/Identity Servers

This is a pretty straightforward process and is necessary for the release portion of this to work. Follow the direction provided by Sitecore here: https://doc.sitecore.com/developers/100/developer-tools/en/configure-a-non-interactive-client-login.html

Configuring the Azure DevOps release pipeline

Create the release pipeline as you normally would. As a final step, add a “Run Inline Powershell” task to the agent. Not listed here in the list are the CM warm scripts…in case you were wondering about them. 🙂

In the inline Powershell, we again install the Sitecore.CLI to the current agents directory. After the agent is installed, we call the Sitecore Install command, passing along the client id, client secret, cm url, and identity server url. The working directory is a parameter that is passed into the script, and the package location is constructed from that. There are better ways to secure your client secrets, but that is a topic for some other time.

That’s it! Happy Serializing!

About Phil Paris

Hi, my name is Phil Paris and I’m a Sitecore Architect and general Sitecore enthusiast. I’ve been working with Sitecore since 2013. Through this blog I will be sharing Sitecore insights, tips and tricks, best practices and general knowledge with the hopes to further the community at large. Please feel free to reach out to me at any time!

View all posts by Phil Paris →