The Bulk publish and unpublish commands allow you to publish entries and assets from multiple content types to one or more environments.
Prerequisites
Commands
To perform bulk publish and unpublish operations on entries and assets, there are a series of commands that you need to run in the CLI.
Let's discuss them in detail.
Bulk Publish All Entries
The cm:entries:publish command lets you publish multiple entries on multiple environments for specific locales.
Usage:
csdx cm:entries:publish --content-types <content_type_uid> --locales <locale_code> -e <environment_name>
Note: To avoid bulk publish failure, we recommend you to bulk publish content of one content type at a time.
Options:
- --content-types=content-types: The UID of the content type(s) whose entries you want to publish in bulk. In case of multiple content types, specify the IDs separated by spaces.
- --locales=locales: Locales in which entries will be published, e.g., en-us. In the case of multiple locales, specify the codes separated by spaces.
- -e, --environments=environments: The name of the environment on which entries will be published. In case of multiple environments, specify their names separated by spaces.
- -a, --alias=alias: Alias (name) of the management token.
- --branch=branch: The name of the branch where you want to perform the bulk publish operation. If you don’t mention the branch name, then by default the content from main branch will be published.
- --publish-all-content-types: (optional) Set it to true to bulk publish entries from all content types. If the contentTypes option is already used, then you cannot use this option.
- --bulk-publish=bulk-publish: Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by default.
- --retry-failed=retry-failed: (optional) Use this option to retry publishing the failed entries/ assets from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.
- -y, --yes: Set it to true to process the command with the current configuration.
- -c, --config=config: (optional) The path of the optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.
Bulk Publish Edited Entries
The cm:entries:publish-modified command lets you publish recently edited entries on a particular environment.
Usage:
csdx cm:entries:publish-modified --content-types <content_type_uid> --source-env <source_environment_name> -e <environment_name> --locales <locale_code>
Options:
- --content-types=content-types: The UID of the content type(s) whose edited entries you want to publish in bulk. In case of multiple content types, specify the IDs separated by spaces.
- --source-env=source-env: The name of the source environment where the entries were initially published.
- -e, --environments=environments: The name of the environment(s) on which the entries will be published. In case of multiple environments, specify their names separated by spaces.
- --locales=locales: Locales in which entries will be published, e.g., en-us. In the case of multiple locales, specify the codes separated by spaces.
- -a, --alias=alias: Alias (name) of the management token.
- --branch=branch: The name of the branch where you want to perform the bulk publish operation. If you don’t mention the branch name, then by default the entries from main branch will be published.
- --bulk-publish=bulk-publish: Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by default.
- --retry-failed=retry-failed: (optional) Use this option to retry publishing the failed entries/assets from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.
- -y, --yes: Set it to true to process the command with the current configuration.
- -c, --config=config: (optional) The path of the optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.
Bulk Publish Draft Entries
The cm:entries:publish-only-unpublished command lets you publish the unpublished or draft entries on any environment(s).
Usage:
csdx cm:entries:publish-only-unpublished --content-types <content_type_uid> --source-env <source_environment_name> -e <environment_name> --locales <locale_code>
Options:
- --content-types=content-types: The UID of the content type(s) whose entries you want to publish in bulk. In case of multiple content types, specify their IDs separated by spaces.
- --source-env=source-env: The name of the source environment where the entries were initially published.
- -e, --environments=environments: The name of the environment on which entries will be published. In case of multiple environments, specify their names separated by spaces.
- --locales=locales: Locale in which entries will be published, e.g., en-us
- -a, --alias=alias: Alias (name) of the management token.
- --branch=branch: The name of the branch where you want to perform the bulk publish operation. If you don’t mention the branch name, then by default the entries from main branch will be published.
- --bulk-publish=bulk-publish: Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by default.
- --retry-failed=retry-failed: (optional) Use this option to retry publishing the failed entries from the logfile. It is optional. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.
- -y, --yes: Set it to true to process the command with the current configuration.
- -c, --config=config: (optional) The path of the optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.
Bulk Publish All Assets
The cm:assets:publish command lets you publish all assets of a particular stack on any environment(s).
Usage:
csdx cm:assets:publish -e <environment_name>
Options:
- -e, --environments=environments: The name of the environment on which entries will be published. In case of multiple environments, specify their names separated by spaces.
- -a, --alias=alias: Alias (name) of the management token.
- --branch=branch: The name of the branch where you want to perform the bulk publish operation. If you don’t mention the branch name, then by default the assets from main branch will be published.
- --bulk-publish=bulk-publish: Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by default.
- --retry-failed=retry-failed: (optional) Use this option to retry publishing the failed assets from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.
- --folder-uid=folder-uid: (optional) The UID of the Assets’ folder from which the assets need to be published. The default value is cs_root.
- --locales=locales: Locales in which assets will be published, e.g., en-us. In the case of multiple locales, specify the codes separated by spaces.
- -y, --yes: Set it to true to process the command with the current configuration.
- -c, --config=config: (optional) The path of the optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.
Bulk Publish Entries/Assets from One Environment to Another
The cm:entries:publish and cm:assets:publish commands let you publish all the entries and assets respectively, from one environment to a newly created or some other environment.
Usage:
csdx cm:entries:publish --source-env <environment_name> -e <destination_environment_name> --content-types <content_type_uid> --locales <locale_code>
or
csdx cm:assets:publish --source-env <environment_name> -e <destination_environment_name> --content-types <content_type_uid> --locales <locale_code>
Options:
- -e, --environments=environments: Target environment.
- --content-types=content-types: The UID of the content type ID whose entries you want to publish in bulk. In case of multiple content types, specify their IDs separated by spaces.
- --locales=locales: Locale in which entries will be published, e.g., en-us
- --bulk-publish=bulk-publish: Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by default.
- --delivery-token=delivery-token: The delivery token of the source environment.
- -a, --alias=alias: Alias (name) of the management token.
- --retry-failed=retry-failed (optional): Use this option to retry publishing the failed entries from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.
- --branch=branch: Branch to fetch the content from (default = main)
- --source-env=source-env: Source environment.
- -y, --yes: Set it to true to process the command with the current configuration.
- -c, --config=config (optional): The path of the optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.
Bulk Publish All Entries after Adding a New Field in the Content Type
If you add a new field(s) to one or more content types, you have to update and publish the corresponding entries manually. To automate this process, the cm:entries:update-and-publish command lets you update and publish such entries in bulk.
Usage:
csdx cm:entries:update-and-publish --content-types <content_type_uid> --locales <locale_code> -e <environment_name>
Options:
- --content-types=content-types: The UID of the content type ID whose entries you want to publish in bulk. In case of multiple content types, specify their IDs separated by spaces.
- --locales=locales: Locales in which entries will be published, e.g., en-us. In the case of multiple locales, specify the codes separated by spaces.
- -e, --environments=environments: The name of the environment on which entries will be published. In case of multiple environments, specify their names separated by spaces.
- --bulk-publish=bulk-publish: Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by default.
- -a, --alias=alias: Alias (name) of the management token.
- --branch=branch: The name of the branch where you want to perform the bulk publish operation. If you don’t mention the branch name, then by default the content from main branch will be published.
- --retry-failed=retry-failed: (optional) Use this option to retry publishing the failed entries from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.
- -y, --yes: Set it to true to process the command with the current configuration.
- -c, --config=config: (optional) The path of the optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.
Bulk Publish Entries after Non-localized Field is Updated
The cm:entries:publish-non-localized-fields command lets you publish the localized entries if the non-localized field of the master entry is updated.
Usage:
csdx cm:entries:publish-non-localized-fields --content-types <content_type_uid> --source-env <source_environment_name> -e <environment_name> -a <management_token_alias>
Options:
- --content-types=content-types: The UID of the content type whose entries you want to publish in bulk. In case of multiple content types, specify their IDs separated by spaces.
- --source-env=source-env: The name of the source environment.
- -e, --environments=environments: The name of the environment on which entries will be published. In case of multiple environments, specify their names separated by spaces.
- --bulk-publish=bulk-publish: Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by default.
- -a, --alias=alias: Alias (name) of the management token.
- --branch=branch: The name of the branch where you want to perform the bulk publish operation. If you don’t mention the branch name, then by default the content from main branch will be published.
- --retry-failed=retry-failed: (optional) Use this option to retry publishing the failed entries from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.
- -y, --yes: Set it to true to process the command with the current configuration.
- -c, --config=config: (optional) The path of the optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.
Restore/Unpublish Entries Published
The cm:stacks:publish-revert command lets you unpublish the published entries and restore their version back to 1.
Usage:
csdx cm:stacks:publish-revert --log-file <logfile_path>
Options:
- --log-file=log-file: Path of the success logfile of a particular publish action.
- --retry-failed=retry-failed: (optional) Use this option to retry publishing the failed entries from the logfile. Specify the name of the logfile that lists failed publish calls. If this option is used, it will override all other flags.
Bulk Unpublish Entries/Assets
The cm:entries:unpublish and cm:assets:unpublish commands let you unpublish entries and assets respectively, of given content types from a given environment.
Usage:
csdx cm:entries:unpublish -e <environment_name> --locale <locale_code>
or
csdx cm:assets:unpublish -e <environment_name> --locale <locale_code>
Options:
- -e, --environment=environment: The name of the environment from where entries/assets need to be unpublished.
- --locale=locale: Locale from which entries/assets will be unpublished, e.g., en-us
- --content-type=content-type: The UID of the content type whose entries you want to unpublish in bulk.
- --bulk-unpublish=bulk-unpublish: Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by default.
- --delivery-token=delivery-token: The delivery token of the source environment.
- -a, --alias=alias: Alias (name) of the management token.
- --branch=branch: The name of the branch where you want to perform the bulk unpublish operation. If you don’t mention the branch name, then by default the content from main branch will be unpublished.
- --retry-failed=retry-failed: (optional) Use this option to retry unpublishing the failed entries from the logfile. Specify the name of the logfile that lists failed unpublish calls. If this option is used, it will override all other flags.
- -y, --yes: Set it to true to process the command with the current configuration.
- -c, --config=config: (optional) Path of an optional configuration JSON file containing all the options for a single run. Refer to the configure command to create a configuration file.
Build the Configuration File
The cm:stacks:publish-configure command lets you generate a template for the configuration JSON file. It will set the variables for the Bulk Publish commands.
After you generate the configuration file, you can simply use its path in the -c , --config=config option of any Bulk Publish commands. You can view this reference configuration file for Bulk Publish commands.
Usage:
csdx cm:stacks:publish-configure
Option:
- -a, --alias=alias: Name (alias) of the management token you want to use
Limitations