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

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
1image: node:16.16.0
2
3# Required to prevent shallow clone warnings (need full git history)
4clone:
5 depth: 'full'
6
7pipelines:
8 pull-requests:
9 '**':
10 - step:
11 name: Install Deps and Build
12 caches:
13 - node
14 script:
15 - yarn
16 - yarn build
17 branches:
18 main:
19 - stage:
20 name: Build and Deploy
21 deployment: Production
22 steps:
23 - step:
24 name: Install Deps and Build
25 caches:
26 - node
27 script:
28 - yarn
29 - yarn build
30 - step:
31 name: Deploy to Heroku
32 script:
33 - |
34 cat > ~/.netrc <<EOF
35 machine git.heroku.com
36 login $HEROKU_EMAIL
37 password $HEROKU_API_KEY
38 EOF
39 - |
40 git remote add heroku $HEROKU_GIT_URL
41 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.