---
url: /en/workspaces/workspace-vs-build.md
description: >
  Clarifies the relationship and differences between Workspaces and Cloud Native
  Build pipelines, explaining that Workspaces is essentially a Cloud Native
  Build pipeline with `service.vscode` declared, and highlighting key
  differences in purpose, default image, node assignment, and billing.
---
## Essential Relationship

Workspace is essentially a **Cloud Native Build** pipeline
with [`service.vscode`](../build/grammar.md#service.vscode) declared.

Both share the same underlying execution mechanism — defined via `.cnb.yml`,
scheduled by the Cloud Native Build engine, and supporting `stages`, `docker`, `imports`,
and other configuration options.

## Core Differences

| Item                | Cloud Native Build                         | Workspace                                |
| ------------------- | ------------------------------------------ | --------------------------------------- |
| **Purpose**         | Automated build, test, and deploy          | Remote development and code writing     |
| **Declaration**     | Define any trigger event in `.cnb.yml`     | Declare `service.vscode` in the pipeline |
| **Default Image**   | `cnbcool/default-build-env`          | `cnbcool/default-dev-env`   |
| **Node Assignment** | Build nodes                                | Dev nodes                                |
| **Billing**         | Cloud Native Build usage                   | Workspace usage                          |

For detailed environment information, see [Build Environment](../build/build-env.md). For node details,
see [Build Nodes](../build/build-node.md). For billing, see [Pricing](../pricing.md).

## Workspace Button

For easier access, the repository branch page provides a 「Workspace」button.
Clicking it triggers a **Workspace event (`vscode`)**,
and the system automatically creates a pipeline with `service.vscode` and starts the development environment.

## Starting a Dev Environment in Non-vscode Events

Not only `vscode` events can create development environments — declaring `service.vscode` in any pipeline also starts a
Workspace environment.

For example, automatically creating a development environment and sending a notification when a branch is created:

```yaml title=".cnb.yml"
(**):
  branch.create:
    - services:
        - vscode
      stages:
        - name: Environment Ready
          script: echo "$CNB_BRANCH dev environment is ready"
```

For more trigger options,
see [Customizing the Dev Environment Creation Process](./custom-dev-pipeline.md#custom-startup-events).

## Auto-Recycling and Timeout

Cloud Native Build pipelines have a maximum execution time of `20h`, after which they are automatically destroyed.
Workspace environments have a maximum retention time of `18h`, plus the following recycling mechanisms:

* **Heartbeat detection**: If no one enters the VSCode page within `10 minutes` after creation,
  or if there is no activity within `10 minutes` after closing the page, the environment is automatically recycled.
* **No overnight policy**: If in use for over `8 hours` and the time falls between 4-6 AM,
  the environment is forcibly recycled.

For details, see [Workspace Recycling](./workspace-recycling.md).

## Code Backup and File Roaming

Workspace environments are designed for on-demand usage with automatic cleanup when idle. To prevent code loss,
the following mechanisms are provided:

* **Code backup**: When an environment is destroyed, uncommitted code (including stash, unpushed commits,
  and workspace changes) is automatically backed up and restored when the environment is rebuilt.
* **File roaming**: Non-workspace config files such as IDE settings and `.gitconfig` roam across environments,
  no reconfiguration needed.

For details, see [Code Backup and File Roaming](./file-keeper.md).

## Business Port Preview

Workspace environments support previewing running business services through their ports.
You can use the WebIDE's `PORTS` panel or VSCode/Cursor client's port forwarding feature.

For details, see [Business Port Preview](./business-preview.md).
