1

I've set up Bitbucket Pipelines to use in different Magento Commerce versions but not Magento Cloud yet.

I usually do like that in Magento Open Source or Magento Commerce:

How to setup CI on Magento 2 extension using Bitbucket Pipeline?

What are the differences using Magento Cloud and how could I set it up?

1 Answer 1

3

First of all, you don't need to integrate Bitbucket Pipelines as you do with your own host provider. You can use the native integration between Magento Cloud and Github, Bitbucket, or Gitlab.

How to setup

This process is a lit bit long to write all so I'm sharing the main steps to you to follow a to-do list, all the process detailed is here in Devdocs. Before starting, make sure you have access to manage the project and manage the Bitbucket account, then install Magento Cloud CLI.

1 - Setup local

You need to do the login using the CLI, get the project using the CLI yet, then add the remote origin of your GIT repo.

2 - Create an OAuth consumer

Open your Bitbucket's account configuration and set a new OAuth consumer to be able to connect using a public and private key. Create a temporary file called bitbucket.json like this below. Run the command to connect your Bitbucket with Magento Cloud and remove the file.

{
  "type": "bitbucket",
  "repository": "<bitbucket-user-name/bitbucket-repo-name>",
  "app_credentials": {
    "key": "<oauth-consumer-key>",
    "secret": "<oauth-consumer-secret>"
  },
  "prune_branches": true,
  "fetch_branches": true,
  "build_pull_requests": true,
  "resync_pull_requests": true
}

And run:

magento-cloud project:curl -p '<project-ID>' /integrations -i -X POST -d "$(< bitbucket.json)"

When it's finished, run this command below to verify the integration and remove the temporary bitbucket.json file.

magento-cloud integrations -p <project-ID>

3 - Webhook

Create a new webhook in your project repository to run the auto-deploy when some code is pushed. You might find the configuration in this path below:

Repository Settings > Workflow > Webhooks

The URL to trigger the event must be the project URL reported in the step above, in the Hook URL.

+----------+-----------+--------------------------------------------------------------------------------+
| ID       | Type      | Summary                                                                        |
+----------+-----------+--------------------------------------------------------------------------------+
| <int-id> | bitbucket | Repository: bitbucket_Account/magento-int                                      |
|          |           | Hook URL:                                                                      |
|          |           | https://magento-url.cloud/api/projects/<project-id>/integrations/<int-id>/hook |
+----------+-----------+--------------------------------------------------------------------------------+

4 - Create Cloud branch

The Bitbucket integration cannot activate new environments in your Magento Cloud project. If you create an environment with Bitbucket, you must activate the environment manually. To avoid this extra step, it is best practice to create environments using the Magento Cloud CLI tool or the Project Web UI.

5 - Test

You just need to push something to your Bitbucket branch and see the Magento Cloud deploying it.

Magento Commerce Cloud + Bitbucket Github Gitlab

1
  • 1
    Note that in order to find the "OAuth consumer" option you need to setup a workspace (team group) and there create the repo. i.e. there isn't such option in a user-based bitbucket repo. you'll find it under workspace settings: https://bitbucket.org/<your-workspace-name-here>/workspace/settings/api (replace <your-workspace-name-here>) Sep 9, 2020 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.