STEPS
- Install Sitecore Management Service package on Sitecore 10.4 CM instance
- Open Visual Studio 2022 with Admin privileges and install Sitecore.CLI package via package console terminal
- Execute: install sitecore.CLI
- Execute: dotnet sitecore init
- The above command will add few JSON files to your project solution under “.sitecore” folder
- RootConfigurationFile.schema.json
- UserConfiguration.schema.json
- ModuleFile.schema.json
- It also adds sitecore.json file to the project solution which needs to be updated
- [Optional] Disable TelemetryEnable in sitecore.json file (set the flag to false)
- Update the path of Modules section in sitecore.json as shown below (I wanted to have all my serialization in single project so i went with current project folder path "./*.module.json")
- You must create a module.json file under the project solution and configure the item structure as shown below (if you prefer to create the module.json in different location then you can do so but make sure to update the path in the sitecore.json)
- E.g. MedicalOneProject.module.json
- Add the item structure in the module.json file as shown below
- Execute the command to connect the CLI to an existing Sitecore CM instance
- sitecore login --authority https://<Identity Server Hostname> --cm https://<CM Hostname> --allow-write true --client-credentials true --client-id Device
- This will open a Sitecore CM instance in the browser to login
- Execute: sitecore ser pull -v (This command will pull the item(s) into project solution)
- Properties for JSON file:
- name : Unique name for serialization
- path : Path of the item to serialize
- scope : Define what content to serialize
- SingleItem: Only the item specified from the Path
- ItemAndChildren: Item specified in path with immediate children
- ItemAndDescendants: Item specified in path including all the descendant items
- DescendantsOnly: Only the descendent items specified form the path
- Ignored: All children and descendants will be ignored, unless in previously matched.
- database : Selected database to sync.
- This can be “master” or “core”
- maxRelativePathLength : Specify how long the path may be,
- by default this is 130 characters
- If the length has been reached it will create a new hashed folder in the root of the directory
- allowedPushOperations : Define how content can be serialized
- CreateOnly: This will only create the item, if it already exists it will be ignored.
- CreateAndUpdate: Creating and updating items. If it already exists but is modified, it will update the item. This setting will not remove items.
- CreateUpdateAndDelete: Items will be created, updated and removed
Serialization Commands:
Note: Following error is thrown when you do not install Sitecore Management Service on Sitecore CM
- sitecore ser pull (pull items from sitecore)
- sitecore ser push (push all the items into sitecore)
- sitecore ser push -w (What if mode is active. No changes will be made.)
Note: Following error is thrown when you do not install Sitecore Management Service on Sitecore CM
Instance.
[CheckGraphQLAvailabilityException] Make sure the GraphQL service is installed
and available. [GraphQLHttpException] Unexpected HttpResponseMessage with code:
Redirect
Other reference:
Configuration to include, exclude items refer
Sitecore Documentation
Command to Create a Sitecore package: sitecore ser pkg
create -o “package name”
Those who wants to leverage the TDS license and looking
for GUI serialization solution then they can install Sitecore for Visual Studio
and configure it. Sitecore documentation
“What do you think about Sitecore CLI? Let me know in
the comments below!”
No comments:
Post a Comment