Environment management with the Contentful CLI
These commands will help you manage environments in Contentful.
Requirements
- A (free) Contentful account
- Locally installed
contentful-cli
- Authenticated with
contentful-cli
List available commands and their description
contentful space environment --help
Create a new environment
This is how you create a new environment within a Space. You have to supply an ID for the environment.
contentful space environment create --name release-1 --environment-id release-1
The output should look similar to this:
Successfully created environment release-1 (release-1)
Clone an existing environment
You have to supply the ID of the source environment that will be copied to create the new environment. The default is "master".
contentful space environment create --name release-2 --environment-id release-2 --source release-1
The output should look similar to this:
Successfully created environment release-1 (release-1)
Get a list of all available environments
Lists all available environments from a Space.
contentful space environment list
The output should look similar to this:
┌──────────────────┬──────────────────┬────────────────────┐
│ Environment name │ Environment id │ Environment status │
├──────────────────┼──────────────────┼────────────────────┤
│ master [active] │ master │ ready │
├──────────────────┼──────────────────┼────────────────────┤
│ release-1 │ <environment-id> │ ready │
└──────────────────┴──────────────────┴────────────────────┘
Set an environment-id to use in all subsequent commands
Many commands have an --environment-id
option since they can be scoped to a specific environment. Since it is unintuitive to pass the environment ID every time, you can use the environment use
command to lock the CLI to a specific environment. It will be used until you use another environment or pass a different --environment-id
to a subsequent command. If you specify a different --space-id
, rather than using the already active space (see space use
) then the current environment will be ignored and 'master'
will be used instead.
contentful space environment use --environment-id <environment-id>
The output should look similar to this:
Now using environment release-1 (<environment-id>) in Space cli-test (<space-id>) when the `--environment-id` option is missing.
Delete an environment in your current space
You have to supply an ID for the environment.
contentful space environment delete --environment-id <environment-id>
The output should look similar to this:
Successfully deleted environment release-1 (<environment-id>)
Next steps
- Manage environment aliases with the Contentful CLI
- Manage extensions with the Contentful CLI
- Check out the documentation in the GitHub repository
Not what you’re looking for? Try our FAQ.