Creating an environment automatically

1 minute read

By default, you must explicitly request a preview using the /preview comment on the pull request. However, you can configure CloudBees Previews to automatically create preview environments as soon as the pull request is created by using the autoCreateContexts configuration.

The auto-creation configuration creates the initial preview environment directly when the pull request is created. If you want the preview environment to be updated as you push changes to the pull request, refer to Updating an environment automatically.

You can configure autoCreateContexts when you create the GitRepository CR, or you dynamically enable or disable it. The autoCreateContexts configuration takes a list of preview contexts for which to enable the auto-create feature:

Enabling auto-create for the default context using kubectl patch
kubectl patch gitrepository acme-web --type merge -p '{"spec":{"autoCreateContexts":["default"]}}'
Disabling auto-create for the default context using kubectl patch
kubectl patch gitrepository acme-web --type merge -p '{"spec":{"autoCreateContexts":[]}}'