Skip to content

Bitbucket Pipeline

Alexander Lukyanov edited this page May 2, 2022 · 15 revisions

Before You Get Started

  1. Review the Pipeline Configuration

Enable Pipelines and Add Variables

Enable Pipelines

To configure pipeline, in Bitbucket go to your repository, open "Repository Settings" from the left navigation bar and select Pipelines->Settings->Enable pipelines.

Add Variables

Then open "Repository Variables" and add at least two variables: MAGENTO_USER and MAGENTO_PASS. These would be Magento composer keys that can be generated at Magento Commerce Marketplace

Additional Repository Variables (Optional)

You may need to add more variables in the case where you use a 3rd party modules that require composer authentication. In the most cases you will have these keys at the auth.json file in your Magento 2 root folder. After you add a custom variables you will need to make changes to a pipeline YML File.

More information


Pipeline For a Composer Module

To setup pipeline:

  1. Copy the example YML file: https://github.com/sashas777/magento-docker-pipelines/blob/master/pipelines/BitBucket_Pipelines/composer_module_bitbucket-pipelines.yml to the Bitbucket repository root.
  2. Rename it to bitbucket-pipelines.yml
  3. Make changes if necessary (Changes To The YML File)

Pipeline For a Module Installation And Compilation

To setup pipeline:

  1. Copy the example YML file: https://github.com/sashas777/magento-docker-pipelines/blob/master/pipelines/BitBucket_Pipelines/module_installation_bitbucket-pipelines.yml to the Bitbucket repository root.
  2. Rename it to bitbucket-pipelines.yml
  3. Make changes if necessary (Changes To The YML File)

Pipeline For a Composer Module And Module Installation, DI Compilation

  1. Copy the example YML file: https://github.com/sashas777/magento-docker-pipelines/blob/master/pipelines/BitBucket_Pipelines/bitbucket-pipelines.yml to the Bitbucket repository root.
  2. Make changes if necessary (Changes To The YML File)

Pipeline For a API-Functional Tests (In Progress)

Example In Progress

What are API-Functional Tests?

The Web API testing framework allows you to test Magento Web API from the client application point of view. The tests can be used with either REST or SOAP. The REST or SOAP adapter that runs the tests is specified in PHPUnit configuration

Get Started

For this pipeline would need to prepare PHPUnit configuration files and place them into the Magento project's dev/config/ folder. The Each file exists at a standard Magento 2 installation:

  • dev/tests/api-functional/config/config-global.php -- Magento DB connection configuration
  • dev/tests/api-functional/config/install-config-mysql.php -- MySql connection configuration
  • dev/tests/api-functional/phpunit.xml

phpunit.xml

PHPUnit configuration for Web API functional tests. It would be. ./../../vendor/{company}/*/Test/Api

<testsuite name="Born Web API Functional Tests">
   <directory suffix="Test.php">../../../app/code/{company}/*/Test/Api</directory>
</testsuite>

Changes To The YML File

There are multiple changes that may apply for a pipeline.

Pipeline triggers

The each pipeline triggers build after commit to the repository's master branch. This can be changed at the line:

  branches:
    master:

There are more information about Pipeline Triggers

Add a 3rd Party Composer Credentials

When you use a 3rd party composer module with a custom credentials you will need to add a new line to the bitbucket-pipelines.yml file.

  1. Find a line composer config --global http-basic.repo.magento.com $MAGENTO_USER $MAGENTO_PASS
  2. Duplicate the line
  3. Change variables and composer URL

For example repository variables were CUSTOM_USER and CUSTOM_PASS and a 3rd party composer URL is repo.custom.com:

....
name: Build
script:
  - composer config --global http-basic.repo.magento.com $MAGENTO_USER $MAGENTO_PASS
  - composer config --global http-basic.repo.custom.com $CUSTOM_USER $CUSTOM_PASS --- The new line with a new keys
  - composer require --dev thesgroup/magento2-testing-framework --no-update
  - composer install --no-suggest --no-ansi --no-interaction --no-scripts
....
 

NOTE: In the case where your pipeline have multiple lines: composer config --global http-basic.repo.magento.com $MAGENTO_USER $MAGENTO_PASS then you will need to add a 3rd party config after the each line.

PHP Version

The PHP image version can be changed at the line:

image: sashas777/magento-php:7.4-cli

ElasticSearch Version

The ElasticSearch image version can be changed at the line:

image: sashas777/magento-elasticsearch:7.9.3

MariaDB Version

The MariaDB image version can be changed at the line:

image: mariadb:10.2

Magento Version

The Magento image version can be changed at the line:

composer create-project --repository-url=https://repo.magento.com/  magento/project-community-edition . --no-interaction --no-ansi --no-dev

You can change Magento version based on Magento Installation Guide

Clone this wiki locally