> ## Documentation Index
> Fetch the complete documentation index at: https://infisical.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Inject secrets into Bitbucket Pipelines

> Fetch secrets from Infisical in Bitbucket Pipelines.

Infisical lets you sync secrets to Bitbucket at the repository-level and deployment environment-level.

Prerequisites:

* Set up and add envars to [Infisical Cloud](https://app.infisical.com)

> [accordion] Push secrets to Bitbucket from Infisical
>
> Use our [Bitbucket Secret Syncs](https://infisical.com/docs/integrations/secret-syncs/bitbucket.md)

> [accordion] Pull secrets in Bitbucket pipelines from Infisical
>
> **1. Configure Infisical Access**
>
> Configure a [Machine Identity](https://infisical.com/docs/documentation/platform/identities/universal-auth.md) for your project and give it permissions to read secrets from your desired Infisical projects and environments.
>
> **2. Initialize Bitbucket variables**
>
> Create Bitbucket variables (can be either workspace, repository, or deployment-level) to store Machine Identity Client ID and Client Secret.
>
> ![integrations bitbucket](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/integrations/bitbucket/integrations-bitbucket-env.png)
>
> **3. Integrate Infisical secrets into the pipeline**
>
> Edit your Bitbucket pipeline YAML file to include the use of the Infisical CLI to fetch and inject secrets into any script or command within the pipeline.
>
> #### Example
>
> ```yaml theme={"dark"}
> image: atlassian/default-image:3
>
> pipelines:
>   default:
>     - step:
>         name: Build application with secrets from Infisical
>         script:
>           - apt update && apt install -y curl
>           - curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash
>           - apt-get update && apt-get install -y infisical
>           - export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=$INFISICAL_CLIENT_ID --client-secret=$INFISICAL_CLIENT_SECRET --silent --plain)
>           - infisical secrets-manager run --projectId=1d0443c1-cd43-4b3a-91a3-9d5f81254a89 --env=dev -- npm run build
> ```
>
> > [!TIP]
> >
> > Set the values of `projectId` and `env` flags in the `infisical secrets-manager run` command to your intended source path. For more options, refer to the CLI command reference [here](https://infisical.com/docs/cli/reference.md#secrets-manager-run).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.