Question

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?

Was it helpful?

Solution

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 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
}

3 - Webhook

Create a new webhook in your project repo to run the auto-deploy when some code is pushed.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top