The environment command

Version: 10.3

The environment command helps you work with environment configurations using Sitecore CLI. The command allows you to show information about the current environment, show a list of environments, and set your default environment.

Usage

The structure for the Sitecore CLI environment command is:

RequestResponse
dotnet sitecore.cli [options] environment [subcommand]

Or:

RequestResponse
dotnet sitecore [options] env [subcommand]

Subcommands

You can use the following subcommands:

  • current - displays the current environment.

  • list - displays the environments from the user configuration file.

  • set-default - sets an environment in user configuration file as the default environment.

  • info - displays information about an environment.

The current subcommand

The current command displays the name of the current environment.

You can use the following options:

Option

Description

-c <configpath>, --config <configpath>

The path to the root sitecore.configdirectory.

Default: current working directory.

?, -h, --help

Help and usage information for the command.

Assuming your current environment is named default, this command displays the name of the current environment (default):

RequestResponse
dotnet sitecore env current

The list subcommand

The list command shows all the environments defined in the configuration file.

You can use the following options:

Option

Description

-c <configpath>, --config <configpath>

The path to the root sitecore.config directory.

Default: current working directory.

?, -h, --help

Help and usage information for the command.

For example, to see all the environments defined in the user.json file, run the following command:

RequestResponse
dotnet sitecore env list

The set-default subcommand

The set-default command sets an environment entry from the specified configuration as the default environment.

You can use the following options:

Option

Description

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

The named Sitecore environment to use.

-c <configpath>, --config <configpath>

The path to the root sitecore.config directory.

Default: current working directory.

-t, --trace

Report additional diagnostic and performance data.

-v, --verbose

Report additional diagnostic and performance data.

?, -h, --help

Help and usage information for the command.

For example, to set the myEnv environment as the default environment, run the following command:

RequestResponse
dotnet sitecore env set-default myEnv

The info subcommand

The info command displays information about a specified environment.

You can use the following options:

Option

Description

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

The named Sitecore environment to use.

-c <configpath>, --config <configpath>

The path to the root sitecore.config directory.

Default: current working directory.

-t, --trace

Report additional diagnostic and performance data.

-v, --verbose

Report additional diagnostic and performance data.

?, -h, --help

Help and usage information for the command.

For example, to see information about a Sitecore environment named myEnv, run the following command:

RequestResponse
dotnet sitecore env info -n myEnv

The response displays the name of the environment, the Content Management (CM) host URL, the version of the instance, and the installed version of Sitecore Management Services (SMS).

Do you have some feedback for us?

If you have suggestions for improving this article,