Setup
Preview environments are configured in three places.
| Where | What it decides |
|---|---|
| The stack's Preview Config tab | When a preview environment is created, and the cloud account it launches into. |
| Each block's Automation tab | Whether new environments include the block, and whether an application deploys on its own. |
| Each preview environment's Automation tab | The same choices for that one environment, plus the pull request or branch it follows. |
Configure the stack
Open the stack and select the Preview Config tab. Each section on this tab has its own Update button.
Launch Settings

Automatically Create Preview Env decides when Nullstone creates a preview environment.
| Option | Behavior |
|---|---|
| Create preview env manually via UI/API | Nothing is created on its own. See Create a preview environment by hand. |
| Create preview env when pull request is opened | A preview environment is created for every pull request opened in a connected repository. |
| Create preview env when pull request is labelled... | A preview environment is created when a pull request gets the label you enter in Pull Request Label. |
Automatically launch when preview env is created launches the environment as soon as it is created. This is the recommended setting for most stacks. Preview environments use limited resources and are destroyed when the pull request is closed. When this is off, the environment is created and waits for you to launch it.
Pull Request Notification Level decides whether Nullstone posts messages to the pull request as the environment launches and deploys.
Cloud Account
Choose the cloud account and region that preview environments launch into. Every preview environment in the stack launches into this account and region.

Shared Blocks
Choose the blocks that are launched once and used by every preview environment. See Shared Infrastructure for how this works and when to use it.
Choose what new preview environments include
A new preview environment starts from the automation defaults of each block in the stack. Open a block, select the Automation tab, and find Automation defaults.

| Setting | Meaning |
|---|---|
enabled | New environments include this block. It is provisioned when the environment launches. |
auto_deploy | When the environment's trigger for the application's repository fires, the application is built and deployed there. Applications only. |
Defaults only affect environments created later. Existing environments keep their current settings. Changing the defaults requires the stack Architect role.
TIP
An application needs a connected repository and a builder other than Manual to auto-deploy. If you don't see your repository when connecting one, make sure you have granted Nullstone access to your GitHub account. Check out the guide to Connect to GitHub.
When auto-deploy is off, deploy your application from your CI/CD pipeline or the Nullstone CLI. See the Deployment guide for more information.
Adjust one preview environment
Every preview environment has its own Automation tab. Use it to change a single environment without touching the defaults.

- Enabled decides whether a block is part of the environment. Infrastructure that an enabled application depends on stays on.
- Auto-deploy decides whether an application deploys on its own in this environment.
- Trigger is set once per repository: the pull request or branch that the environment follows. A commit pushed to it builds and deploys every application of that repository that has auto-deploy on.
A preview environment created for a pull request follows that pull request. Click Save to apply your changes. Changing automation requires the stack Architect role.
You can make the same changes from a script with nullstone envs apps set.
Create a preview environment by hand
Open the stack's overview and click New Preview.

- Enter a name for the environment.
- Select the applications to launch.
- For each repository, choose the pull request or branch to deploy.
- Click
Create.
Build Configuration
How an application is built is its build configuration, which is set per environment. A new preview environment starts with the build configuration from the block's Template tab.
- For applications packaged as Docker images, specify the build directory and Dockerfile to use.
- For static sites, specify the commands that build the site and the directory to deploy.
See Automatic Build for every setting and where to change it.
IaC Files
To further control the configuration of your preview environment, you can add Infrastructure as Code (IaC) files to your application's repo.
.nullstone/config.yml
To fully control the capabilities, variables, and environment variables of your application, you can provide a .nullstone/config.yml file. When your application is launched as part of a preview environment, Nullstone will use the configuration in this file to determine the infrastructure. The contents of this file replace the entire configuration. Be sure to include all the configuration you want for your application.
This allows you to make changes to your infrastructure alongside your code changes and merge them together in a single PR. e.g. If you want to add a connection to a Redis cache as part of new feature, add the capability to the .nullstone/config.yml file. Then, add the code for your new feature and open your PR. The infrastructure and new feature will be launched together.
.nullstone/previews.yml
An additional file that can be used to configure your preview environments is .nullstone/previews.yml. This file only allows you to override settings for preview environments: variables, environment variables, and the build configuration of an application. In most cases you only need minimal infrastructure resources like CPU or memory for your preview environments. Override the values for these variables in the .nullstone/previews.yml file to control these settings for your preview environments.
TIP
To learn more about the options and syntax for IaC files, check out the Infrastructure as Code guide.