We chose many ideas and finally ended up completing Job related plugin.
This Sitecore Job plugin will enable developers/admins to
- View currently running, queued and finished jobs. Also lists configured Sitecore Database jobs.
- Execute Sitecore Database jobs on-demand
- Rebuild the Link database
There are two parts in developing a Sitecore CLI Plugin.
- Plugin (published in nuget.org)
- Sitecore Management Service to initiate the action in Sitecore Context.
Installation instructions:
- Sitecore instance (10.2) with Sitecore Management Services package installed. Setup a project folder in your workstation. Install and initiate the Sitecore CLI as mentioned in this document.
- As part of this job plugin, we have created a management service which can receive the request from the CLI and execute the action in Sitecore. The management service package is placed here. This package can be installed using Sitecore Installation Wizard.
- To install the job plugin, Sitecore has provided a plugin called plugin. You can pass on the plugin name along with add subcommand. Please note that this plugin is already published to nuget.org here.
dotnet sitecore plugin add -n SitecoreWarriors.DevEx.Extensibility.Jobs - To verify whether job plugin has been installed successfully, you can run dotnet sitecore job -h.
Usage:
dotnet sitecore job [subcommand] [options]
Subcommands:
You can use the following subcommands:
- list - Get all jobs list (running, queued, finished and db task jobs). Db task can be started on-demand.
- rebuildlinkdb - Start rebuilding a link db.
- start - Start a DB task.
You can use the following options with the list subcommand:
Option | Explanation |
---|---|
-c, --config (config) | Path to root sitecore.json directory (default: cwd) |
-v, --verbose | Write some additional diagnostic and performance data |
-t, --trace | Write more additional diagnostic and performance data |
-?, -h, --help | Show help and usage information |
You can use the following options with the start subcommand:
Option | Explanation |
---|---|
-c, --config (config) | Path to root sitecore.json directory (default: cwd) |
-j, --job-name (job-name) | Mention DB Task Schedule Name from Listing. |
-v, --verbose | Write some additional diagnostic and performance data |
-t, --trace | Write more additional diagnostic and performance data |
-?, -h, --help | Show help and usage information |
You can use the following options with the rebuildlinkdb subcommand:
Option | Explanation |
---|---|
-c, --config (config) | Path to root sitecore.json directory (default: cwd) |
-db, --database (database) | Mention DB name for rebuilding the link DB (default: master) |
-v, --verbose | Write some additional diagnostic and performance data |
-t, --trace | Write more additional diagnostic and performance data |
-?, -h, --help | Show help and usage information |
Demo:
- Install the job Sitecore management service package.
- In order for Sitecore CLI to interact with Sitecore Management Services, we need to login and obtain the access token.
dotnet sitecore login
- Install the job plugin.
dotnet sitecore plugin add -n SitecoreWarriors.DevEx.Extensibility.Jobs - Get the list of commands in job plugin.
dotnet sitecore job -h - To view the list of running, queued, finished and DB tasks.
dotnet sitecore job list - To start a DB task. The last run changes once the job gets executed.
dotnet sitecore job start -j {JobName} - To rebuild the link database.
dotnet sitecore job rebuildlinkdb -db master
Sitecore CLI is a powerful tool to automate admin tasks and integrate it as part of DevOps. Since additional plugins can be added easily, this tool can integrate not only with Sitecore XM/XP, it can be leveraged for other Sitecore product family with few customization.
No comments:
Post a Comment