The CLI publish command

Abstract

Reference of the DevEx CLI publish command that publishes Sitecore Items.

The Sitecore publishing plugin includes a publish command. This command publishes Sitecore Items.

You can use the command as follows:

sitecore publish [options]

You can use the following options with the publish command:

Option

Required?

Description

-n, --environment-name <environment-name>

Optional

The Sitecore environment to use. Default: default.

-c, --config <CONFIG>

Optional

Path to root sitecore.config directory (default: cwd).

-l, --languages <languages>

Optional

Comma-separated list of languages to publish. If unspecified, then all languages are published.

-p, --path <path>

Optional

Sitecore item path or GUID to smart publish. If unspecified, then the full database is published.

-r, --republish

Optional

Use republish. If unspecified, then smart-publish is used instead.

-v, --verbose

Optional

Report additional diagnostic and performance data.

-t, --trace

Optional

Report additional diagnostic and performance data.

-?, -h, --help

Optional

Help for the publish command.

The following are examples of the publish command use:

Command

Result

Attempt to publish from the samples folder:

 sitecore publish

Does not publish Sitecore items and returns the following message:

error: Couldn't resolve a root configuration file (sitecore.json) in the current or any parent directory. Looks like the command may have been executed outside a Sitecore project?

Attempt to publish from the samples folder:

sitecore publish -c Prototype/

Publishes the Sitecore items from the folder samples.

sitecore publish -n testEnv

Publishes Sitecore items to the environment with the name testEnv.

sitecore publish -l en-US,en-CA

Publishes Sitecore items for only the specified languages (en-US,en-CA).

sitecore publish -p '/sitecore/content/Home/Test Item'

Publishes only the item with path /sitecore/content/Home/Test Item.

sitecore publish -v

Creates additional diagnostic and performance data, such as root config path or count of nodes with performance, for example, 73ms (8.1ms/node).

sitecore publish -t

Creates additional diagnostic and performance data, such as FSIndex: Loaded filesystem indices in, for example, 70ms (9 metadatas) or created package of 1 trees in, for example, 1983ms (9 items; 220.3ms/node).