> For the complete documentation index, see [llms.txt](https://docs.duplocloud.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.duplocloud.com/docs/automation-platform/introduction-to-ci-cd/bitbucket-pipelines/configure-bitbucket.md).

# Configure Bitbucket

## Prerequisites

To use Pipelines, you need to:

* Create a `bitbucket-pipelines.yml` file in your repository's `root` directory. This file contains the configuration for your builds and deployments.
* Deploy the application with DuploCloud as a Service and test that it works as expected.

{% hint style="info" %}
Bitbucket Pipelines are only recommended to be used for upgrades of container images and to run tests that can be written to run either before or after.
{% endhint %}

## Configuring BitBucket Pipelines

Configure BitBucket Pipelines for use with DuploCloud:

1. Create a [repository variable](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/) for the `DUPLO_TOKEN`. Set the variable at the project or workspace level or even in a [deployment](https://support.atlassian.com/bitbucket-cloud/docs/set-up-and-monitor-bitbucket-deployments/). Create service account users in DuploCloud by assigning a user name, such as `bitbucket`. Ensure the user name is not an email to avoid confusion.
2. Retrieve a token for the user (`bitbucket`) that you set up.
3. Use [OpenID Connect](https://auth0.com/resources/ebooks/the-openid-connect-handbook?utm_content=usoidc-openid-openidconnecthandbookebk\&utm_source=google\&utm_campaign=amer_mult_usa_all_ciam-dev_dg-ao_auth0_search_google_text_kw_utm2\&utm_medium=cpc\&utm_term=oidc-c\&utm_id=aNK4z0000004GwDGAU\&gclid=CjwKCAiAxvGfBhB-EiwAMPakqiIwYI1KhG2WYXEcZfw_CBsOwuTOKuC4xCq4hTp9-EGTAlySZZ8vphoC-hMQAvD_BwE) (OIDC) by setting up an OpenID login with [Bitbucket Pipelines](https://support.atlassian.com/bitbucket-cloud/docs/integrate-pipelines-with-resource-servers-using-oidc/).
4. After configuring the OIDC provider by using [AWS IAM](https://docs.aws.amazon.com/singlesignon/latest/userguide/idp.html), the IAM role needs an associated trust relationship. For example:

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "BitbucketWorkspace",
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::{account id}:oidc-provider/api.bitbucket.org/2.0/workspaces/{workspace}/pipelines-config/identity/oidc"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "api.bitbucket.org/2.0/workspaces/{workspace}/pipelines-config/identity/oidc:aud": "ari:cloud:bitbucket::workspace/{workspace id}"
                }
            }
        }
    ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.duplocloud.com/docs/automation-platform/introduction-to-ci-cd/bitbucket-pipelines/configure-bitbucket.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
