XM Cloud - Exclude SCS Modules From Deploy
Summary
We wanted to give developers the ability to have content in their local Sitecore XM Cloud environment for easy setup and development. However, we did not want this content to make it out to our upper DEV, QA and PROD environments.
The Solution
XM Cloud uses Sitecore Content Serialization (SCS) to control what items get deployed to Sitecore during the deployment process to XM Cloud. For more information on SCS and how it works check out the official Sitecore documentation here. (opens in a new tab)
Below is a very simple example of a project.module.json
file called Project
that serializes your templates and renderings.
{
"$schema": "../.sitecore/schemas/ModuleFile.schema.json",
"namespace": "Project",
"items": {
"includes": [
{
"name": "Templates",
"path": "/sitecore/templates/Project",
"scope": "itemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
},
{
"name": "Renderings",
"path": "/sitecore/layout/Renderings/Project",
"scope": "itemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
}
]
}
}
If you wanted to serialize your content you would make a new content.module.json
called Content
like shown below.
{
"$schema": "../.sitecore/schemas/ModuleFile.schema.json",
"namespace": "Content",
"items": {
"includes": [
{
"name": "HeadlessSite",
"path": "/sitecore/content/HeadlessTenant/HeadlessSite",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
}
]
}
}
Finally, you modify your xmcloud.build.json
and add a deployItems
section where you specify the modules you want to deploy. In our case we want to deploy the Project
module, but not the Content
module.
{
"renderingHosts": {
"xmcloudpreview": {
[TRUNCATED FOR EXAMPLE]
}
},
"deployItems": {
"modules": [
"Project"
]
},
"postActions": {
[TRUNCATED FOR EXAMPLE]
}
}
As long as you have your sitecore.json
file set up to parse all the modules in your directory the Content
module will now only be deployed locally and never to XM Cloud.
Conclusion
XM Cloud gives us the flexibility to specify what content actually gets deployed to XM Cloud. Using the deployItems
setting keeps developers focused on technical tasks locally, without without the extra overhead of content infrastructure.
Special thanks to Tim Shanahan (opens in a new tab) for collaborating with me on this post.