Updating an environment automatically

1 minute read

By default, a user needs to explicitly request a preview using the /preview comment on the pull request. You must repeat the comment on each update to the pull request in order to get an updated environment. You can, however, configure CloudBees Previews to automatically update a preview environment on each push to the pull request using the autoUpdate configuration.

Even with autoUpdateContexts enabled, you must request the initial preview creation using the /preview comment. If you want the preview environment to be created together with the pull request, have a look at Creating an environment automatically.

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

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