Using the Sitecore CLI in a continuous delivery pipeline
Learn how to automate Sitecore 10 content serialization and deployment using the Sitecore CLI in a continuous delivery pipeline. This guide covers the hidden dependencies of the CLI and provides a step-by-step process to streamline your deployment workflows.
Sitecore 10 introduced a new approach for managing serialized content, blending concepts from both Unicorn and TDS. With this change, items can be deployed directly through the Sitecore web service rather than requiring deployment to the server using the Sitecore Command Line Tool.
Sitecore’s documentation for the CLI is comprehensive when it comes to setup and basic usage. However, it provides limited guidance on how to integrate the CLI effectively within a continuous delivery pipeline. Combined with the CLI’s hidden dependencies, this makes automating the process more challenging than expected.
These dependencies include:
- A NuGet configuration file
- A local configuration folder
- Default Sitecore serialization configurations
While it is possible to package these dependencies with your deployment artifacts, a cleaner approach is to automate their creation during the pipeline execution.
Steps for Automating Sitecore CLI Setup
- Create an empty NuGet configuration file
- Add the Sitecore source to the NuGet configuration
- Create a new tool manifest (or Overwrite the existing One)
- Install the Sitecore CLI
- Initialize the Sitecore CLI
- Add required Plugins
- Run the Serialization Script to install a Package
This approach handles all dependencies dynamically, simplifying the integration of Sitecore content serialization and deployment into automated delivery pipelines.
The following example demonstrates how to achieve this using a PowerShell script. Ensure that the Identity, Content Management, Client ID, and Client Secret values are updated to match the configuration of your Sitecore environment.