---
title: "Bitbucket Pipelines"
description: "Use Ennote secrets in Bitbucket Pipelines: store an Ennote token as a secured repository or deployment variable, install the Ennote CLI in the step, and inject secrets with ennote secret get."
canonical_url: "https://docs.ennote.io/guides/ci-cd/bitbucket"
---
# Bitbucket Pipelines

> Use Ennote secrets in Bitbucket Pipelines: store an Ennote token as a secured repository or deployment variable, install the Ennote CLI in the step, and inject secrets with ennote secret get.

## How it works

Bitbucket stores one Ennote token as a secured variable, which every step receives as an environment variable. The step installs the Ennote CLI, and `ennote secret get <secret> -- <command>` runs the command with the keys of the secret as environment variables. See the [CI/CD overview](https://docs.ennote.io/guides/ci-cd/overview) for the common setup.

## 1. Create a token

Create a [Personal Access Token](https://docs.ennote.io/docs/auth/user-tokens) with an expiration, and copy it.

## 2. Store it in Bitbucket

In your repository, open **Repository settings → Pipelines → Repository variables**, add `ENNOTE_TOKEN` with the token and select **Secured**. Add `ENNOTE_ORGANIZATION_ID` the same way (it does not need to be secured).

To use a different workspace per environment, add `ENNOTE_WORKSPACE_ID` as a **deployment variable** instead: **Repository settings → Pipelines → Deployments**, then set it for Staging and Production separately.

## 3. Add the pipeline

```yaml [bitbucket-pipelines.yml]
image: node:22

pipelines:
  branches:
    main:
      - step:
          name: Deploy to production
          deployment: production
          script:
            - export ENNOTE_DO_NOT_TRACK=1
            - curl -sSfL https://get.ennote.io/get-cli.sh | sh
            - ennote secret get db-credentials -- npm run migrate
            - ennote secret get aws -- ./deploy.sh
```

`ENNOTE_TOKEN`, `ENNOTE_ORGANIZATION_ID` and `ENNOTE_WORKSPACE_ID` come from the repository and deployment variables. Replace `db-credentials` and `aws` with your secret names.

The `node:22` image runs as root and includes `curl`, so the install script works as is. On Alpine-based images, add `apk add --no-cache curl` before it.

## Several Steps

Each Bitbucket step runs in a fresh container, so install the CLI at the start of every step that runs `ennote`. To skip the download, build your own CI image with the CLI preinstalled and use it as the `image`.

## FAQ

### Are secured variables shown in logs?

Bitbucket masks secured variables in the log, so the token is not shown. Values fetched by `ennote secret get` are not known to Bitbucket, so don't print them.

### Do I need `ennote auth login`?

No. With `ENNOTE_TOKEN` set, the CLI authenticates headlessly ([ennote auth](https://docs.ennote.io/cli/commands/auth)).

<need-help>



</need-help>


## Sitemap

See the full [sitemap](https://docs.ennote.io/sitemap.md) for all pages.
