Bash Scripts

  1. Download these files.

  2. Integrate the files in your CI by setting them to trigger as follows:

File nameEvent trigger
bit-init.shStart of every CI job
verify.shOn git push
pull-request.shOn new or modified PR
tag-export.shOn merge to main (approved PR)
commit-bitmap.shAfter merge to main (commits changes in workspace, back. Make suer to use a comment to skip the CI)
  1. Create a permanent access token for your CI. Lean how in the generating an access token section.

  2. Add the following environment variables to your CI system:

Environment VariableValue/Description
BIT_CLOUD_ACCESS_TOKENa bit.cloud access token with permission levels required for your workflow
BIT_CONFIG_INTERACTIVEfalse
BIT_CONFIG_ANALYTICS_REPORTINGfalse
BIT_CONFIG_ANONYMOUS_REPORTINGfalse
GIT_USER_NAMEa username for git commits made by the CI
GIT_USER_EMAILan email for git commits made by the CI

To learn more see the docs for this implementation of the workflow, or read the in-depth' section below.

Generating an access token

Create a permanent access token for your CI with the proper permissions to install, import and export components in the relevant scopes.

Head over to your organization page on bit.cloud, then click on the 'settings' tab, and then on the 'access tokens' tab.

An in-depth look at the workflow

CI job initial steps: Set up Bit

These steps should precede any sequence of CI steps that use Bit.

Install BVM globally

$npm i -g @teambit/bvm
Copiedcopy

To troubleshoot installation issues, see BVM Troubleshooting section.

Set the PATH environment variable to include the BVM installation directory:

$export PATH=$HOME/bin:$PATH
Copiedcopy
Install Bit globally
$bvm install
Copiedcopy

Turn off interactive mode

$bit
Copiedcopy
See command synopsis

Alternatively, you can set the BIT_CONFIG_INTERACTIVE environment variable to false.

Turn off analytics reporting

$bit
Copiedcopy
See command synopsis
$bit
Copiedcopy
See command synopsis

Alternatively, you can set the BIT_CONFIG_ANALYTICS_REPORTING and BIT_CONFIG_ANONYMOUS_REPORTING environment variables to false.

Set your package manager to use the bit.cloud registry

Set your package manager to use the bit.cloud registry for Bit components. This should only be done if you plan to install Bit components using a package manager (instead of Bit). To learn more see installing components.

$npm config set @teambit:registry https://node-registry.bit.dev
Copiedcopy
$npm config set @my-org:registry https://node-registry.bit.dev
Copiedcopy

The above shows how to set npm to use the bit.cloud registry fro components from teambit and from my-org bit.cloud account (replace my-org with your organization name or username).

Set a token for the bit.cloud registry:

$npm config set //node-registry.bit.cloud/:_authToken eb278fa1-7798-4d14-b052-f084c30edc42
Copiedcopy

Get the token of a user by running bit config get user.token in the terminal, where the user is logged in.

On push to remote: validate changes

The following steps should be executed on every push to the remote repository.

Strict status check

The CI should verify no issues are found in your workspace (e.g missing dependencies, etc).

$bit
Copiedcopy
See command synopsis

Use the strict option to exit with code 1 when issues are found (use this exit code to stop the CI).

Build components

When developing in a local workspace, Bit prioritizes performance and dev experience for each component's test and build process. When you push any modified component to the branch, Bit needs to run the entire isolation process for each component.

$bit
Copiedcopy
See command synopsis

On new or updated pull-request: validate changes

The following steps should be executed on every new or updated pull-request.

Create a new lane

Create a new lane to make the changes available for review in a remote scope, isolated from the main lane.

$bit
Copiedcopy

In case of a PR update, a lane with the same ID already exists. To address that, it is better to verify first the lane is not available in the remote scope by running: bit lane list --remote ACCOUNT.SCOPE. To remove the remote lane run: bit lane remove LANE_ID --remote.

Strict status check

The CI should verify no issues are found in your workspace (e.g missing dependencies, etc).

$bit
Copiedcopy
See command synopsis

Use the strict option to exit with code 1 when issues are found (use this exit code to stop the CI).

Snap the components to the new lane

Build and snap components to the new lane.

$bit
Copiedcopy

Export the lane

$bit
Copiedcopy

Note that workspace changes are not committed back to the branch as they are only used for review and verification. The development in this branch is done on the main branch.

The components are available for review in the workspace's default remote scope at https://bit.cloud/ACCOUNT/SCOPE/~lane/LANE_ID.

On merge to main: release components

The following steps should be executed on every merge to the main branch.

Tag components

Modified components are snapped and tagged with a semantic release version. Byt default, the patch number is increased. You can use the --minor or --major flags to increase the minor or major version numbers.

$bit
Copiedcopy
See command synopsis

Export components

$bit
Copiedcopy
See command synopsis

Commit changes back to repository

Once the modified components are tagged, the .bitmap file is updated with the components' new versions. In addition, temporary component configurations that were added to the .bitmap file are removed, as they are now stored in the component snaps.

Include the bitmap file

$git add .bitmap
Copiedcopy

Commit with Skip-CI

Ensure your CI system allows you to merge back to main while skipping the CI, to prevent an infinite loop.

$git commit -m "update .bitmap with new component versions (automated). [skip-ci]"
Copiedcopy

Push changes

Push the latest changes to the origin repository.

$git push
Copiedcopy