Skip to navigation

Bitbucket

Bitbucket is a versatile Git hosting service that supports collaborative code development and version control.
View as Markdown

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โ€

A repository access token grants access to this one repository only. You can revoke it at any time from the same Access tokens page; cloud authoring for the repository stops working until a new token is delivered.

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

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)
  3. HEROKU_GIT_URL โ€” Located on the app dashboard within Herokuโ€™s admin interface
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.