> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.knapsack.cloud/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.knapsack.cloud/_mcp/server.

# Bitbucket

## Overview

Bitbucket integrates seamlessly with Knapsack, enabling efficient management of your design system and component library. Bitbucket's cloud-based platform provides robust features, including pull requests, inline commenting, and CI/CD integration, making it an excellent choice for development teams of all sizes.

### Cloud Authoring

#### Authentication through Access Token

To enable cloud authoring within Bitbucket Cloud we use an Access Token for authentication. This token allows secure access to your Bitbucket repository and enables necessary actions on your behalf.

#### Permissions Required

You may need elevated privileges on your repository to generate a new Access Token. If you encounter any issues, please reach out to our support team for assistance.

### Step 1: Generate an Access Token

1. Log into Bitbucket and navigate to the repository containing Knapsack.
2. In the left sidebar click "Repository settings".
3. Next, click "Access tokens" under "Security" (Security » Access tokens)
4. Name your token (i.e. Knapsack) and provide these scopes/permissions:
   1. Repository — Read and Write
   2. Pull requests — Read and Write
5. Click "Create"

### Step 2: Deliver Securely

1. Setup a meeting with your Knapsack representative.
2. Deliver securely the Access Token.

![Screenshot 2024-07-18 at 12.02.13 PM.png](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/knapsack-docs.docs.buildwithfern.com/62484471ef164942da232b2c15c4f79b47cf856bffa561380dff5ace122eaaa4/docs/assets/images/435d7165-screenshot-2024-07-18-at-120213-pm-qctaf8t9zepng.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260724%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260724T211737Z&X-Amz-Expires=604800&X-Amz-Signature=afe280a13a7d5f660d77bb12d45df57f09bb745477a5d0f9127f41ed532a5539&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

### Step 3: Knapsack completes integration

1. Knapsack adds the Access Token to our secure database.

2. We run tests to verify the integrity of cloud authoring capabilities.

3. We notify you when its all done. 🎉

***

## Bitbucket Pipelines

### Required Deployment Variables

Deployments to Heroku rely on the following deployment variables:

1. `HEROKU_EMAIL` — The email associated with the Heroku account.
2. `HEROKU_API_KEY` — The API Key associated with the Heroku account (found in [profile settings](https://dashboard.heroku.com/account))
3. `HEROKU_GIT_URL` — Located on the app dashboard within Heroku's admin interface

```yaml title="Example bitbucket-pipelines.yml"
image: node:16.16.0

# Required to prevent shallow clone warnings (need full git history)
clone:
  depth: 'full'

pipelines:
  pull-requests:
    '**':
      - step:
          name: Install Deps and Build
          caches:
            - node
          script:
            - yarn
            - yarn build
  branches:
    main:
      - stage:
          name: Build and Deploy
          deployment: Production
          steps:
            - step:
                name: Install Deps and Build
                caches:
                  - node
                script:
                  - yarn
                  - yarn build
            - step:
                name: Deploy to Heroku
                script:
                  - |
                    cat > ~/.netrc <<EOF
                      machine git.heroku.com
                        login $HEROKU_EMAIL
                        password $HEROKU_API_KEY
                    EOF
                  - |
                    git remote add heroku $HEROKU_GIT_URL
                    git push heroku main
```

### In this example

* For any pull request, the pipeline installs dependencies and builds the application.
* For the `main` branch, the pipeline performs two steps:
  1. **Install Deps and Build**: Installs dependencies and builds the application.
  2. **Deploy to Heroku**: Deploys the built application to Heroku using authentication details provided through environment variables.