-
-
Notifications
You must be signed in to change notification settings - Fork 0
GitLab CI CD Pipeline
- Review the Pipeline Configuration
To enable or disable GitLab CI/CD pipelines in your project:
- On the top bar, select Menu > Projects and find your project.
- On the left sidebar, select Settings > General.
- Expand Visibility, project features, permissions.
- In the Repository section, turn on or off CI/CD as required.
Press Save changes for the settings to take effect.
Add at least two variables: MAGENTO_USER and MAGENTO_PASS. These would be Magento composer keys that can be generated at Magento Commerce Marketplace
- Go to your project’s Settings > CI/CD and expand the Variables section.
- Select the Add Variable button and fill in the details:
An Example:
- Key: MAGENTO_USER
- Value: {key}
- Type: Variable.
- Environment scope: All
- Protect variable: Yes
- Mask variable: Yes
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.
To setup pipeline:
- Copy the example YML file: https://github.com/sashas777/magento-docker-pipelines/blob/master/pipelines/GitLab_CI/composer_module.gitlab-ci.yml to the repository root.
- Rename it to .gitlab-ci.yml
- Make changes if necessary (Changes To The YML File)
There are multiple changes that may apply for a pipeline.
The each pipeline triggers build after commit to the repository. This can be changed based on the official documentation:
Example only on master branch:
...
install:
stage: build
only:
- master # Limit this job to the master branch
cache:
....
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.
- Find a line
composer config --global http-basic.repo.magento.com $MAGENTO_USER $MAGENTO_PASS
- Duplicate the line
- 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:
....
cache:
key: $CI_COMMIT_SHA
paths:
- vendor/
- composer.lock
script:
- composer config --global http-basic.repo.magento.com $COMPOSER_USER $COMPOSER_PASSWORD
- 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-scripts --no-suggest --no-ansi --no-interaction --no-progress
....
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.
The PHP image version can be changed at the line:
image: sashas777/magento-php:7.4-cli