Bitbucket connections - AWS CodePipeline

Bitbucket connections

Connections allow you to authorize and establish configurations that associate your third-party provider with your AWS resources. To associate your third-party repository as a source for your pipeline, you use a connection.

Note

This feature is not available in the Asia Pacific (Hong Kong) or Europe (Milan) Region. To use other source actions available in that Region, see Source action integrations.

To add a Bitbucket Cloud source action in CodePipeline, you can choose either to:

Note

You can also create a connection using the Developer Tools console under Settings. See Create a Connection.

Before you begin:

  • You must have created an account with the provider of the third-party repository, such as Bitbucket.

  • You must have already created a third-party code repository, such as a Bitbucket repository.

Note

Bitbucket connections only provide access to repositories owned by the Bitbucket account that was used to create the connection.

Create a connection to Bitbucket (console)

Use these steps to use the CodePipeline console to add a connections action for your Bitbucket repository.

Note

You can create connections to a Bitbucket Cloud repository. Installed Bitbucket provider types, such as Bitbucket Server, are not supported.

Step 1: Create or edit your pipeline

To create or edit your pipeline

  1. Sign in to the CodePipeline console.

  2. Choose one of the following.

    • Choose to create a pipeline. Follow the steps in Create a Pipeline to complete the first screen and choose Next. On the Source page, under Source Provider, choose Bitbucket.

      
                                    Console screenshot showing the Add source stage dialog
                                        box with Bitbucket chosen as the source provider.
      
                                    Console screenshot showing the Add source stage dialog
                                        box with Bitbucket Cloud chosen as the source
                                        provider.
    • Choose to edit an existing pipeline. Choose Edit, and then choose Edit stage. Choose to add or edit your source action. On the Edit action page, under Action name, enter the name for your action. In Action provider, choose Bitbucket.

  3. Do one of the following:

    • Under Connection, if you have not already created a connection to your provider, choose Connect to Bitbucket. Proceed to Step 2: Create a Connection to Bitbucket.

    • Under Connection, if you have already created a connection to your provider, choose the connection. Proceed to Step 3: Save the Source Action for Your Connection.

Step 2: Create a connection to Bitbucket

To create a connection to Bitbucket

  1. On the Connect to Bitbucket settings page, enter your connection name and choose Connect to Bitbucket.

    
                            Console screenshot showing the Connect to Bitbucket
                                button.

    The Bitbucket apps field appears.

  2. Under Bitbucket apps, choose an app installation or choose Install a new app to create one.

    Note

    You install one app for all of your connections to a particular provider. If you have already installed the Bitbucket app, choose it and move to step 4.

    
                            Console screenshot showing the Connect to Bitbucket dialog box,
                                with the install new app button.
  3. If the login page for Bitbucket displays, log in with your credentials and then choose to continue.

  4. On the app installation page, a message shows that the AWS CodeStar app is trying to connect to your Bitbucket account. Choose Grant access.

    
                            Console screenshot showing request for
                                access.
  5. In Bitbucket apps, the connection ID for your new installation is displayed. Choose Connect. The created connection displays in the connections list.

    
                            Console screenshot showing request for
                                access.

Step 3: Save your Bitbucket source action

Use these steps on the wizard or Edit action page to save your source action with your connection information.

To complete and save your source action with your connection

  1. In Repository name, choose the name of your third-party repository. In Branch name, choose the branch where you want your pipeline to detect source changes.

  2. In Output artifact format, you must choose the format for your artifacts.

    • To store output artifacts from the Bitbucket action using the default method, choose CodePipeline default. The action accesses the files from the Bitbucket repository and stores the artifacts in a ZIP file in the pipeline artifact store.

    • To store a JSON file that contains a URL reference to the repository so that downstream actions can perform Git commands directly, choose Full clone. This option can only be used by CodeBuild downstream actions.

      If you choose this option, you will need to update the permissions for your CodeBuild project service role as shown in Add CodeBuild GitClone permissions for connections to Bitbucket, GitHub, or GitHub Enterprise Server.

  3. Choose Next on the wizard or Save on the Edit action page.

Create a connection to Bitbucket (CLI)

You can use the AWS Command Line Interface (AWS CLI) to create a connection.

Note

You can create connections to a Bitbucket Cloud repository. Installed Bitbucket provider types, such as Bitbucket Server, are not supported.

To do this, use the create-connection command.

Important

A connection created through the AWS CLI or AWS CloudFormation is in PENDING status by default. After you create a connection with the CLI or AWS CloudFormation, use the console to edit the connection to make its status AVAILABLE.

To create a connection

  1. Open a terminal (Linux, macOS, or Unix) or command prompt (Windows). Use the AWS CLI to run the create-connection command, specifying the --provider-type and --connection-name for your connection. In this example, the third-party provider name is Bitbucket and the specified connection name is MyConnection.

    aws codestar-connections create-connection --provider-type Bitbucket --connection-name MyConnection

    If successful, this command returns the connection ARN information similar to the following.

    { "ConnectionArn": "arn:aws:codestar-connections:us-west-2:account_id:connection/aEXAMPLE-8aad-4d5d-8878-dfcab0bc441f" }
  2. Use the console to complete the connection. For more information, see Update a pending connection.