Intelligent Build Pipelines
from Jenkins to Gitlab
netz98 GmbH - Christian Münch / @cmuench 1
Jenkins
2
Jenkins Job List
netz98 GmbH - Christian Münch / @cmuench 3
Jenkins Job
netz98 GmbH - Christian Münch / @cmuench 4
Current Jenkins Setup
4 1 Job for every Magento Module (sometimes two CE/EE)
4 1 Magento Installation for every Magento Module
4 1 Database for every Magento Module
4 1 extra database for Integration tests
4 Manually compiled PHP versions.
4 Software is directly installed on host
4 Only few commits in most M1 repos
netz98 GmbH - Christian Münch / @cmuench 5
Disk Space! -> Magento 1 Modules
4 1x Magento 1 Module
4 Webroot: 175 MB
4 Database: 62 MB
4 Total with Log-Data: ~200 MB
4 50x Magento 1 Module -> 10 GB
netz98 GmbH - Christian Münch / @cmuench 6
Disk Space! -> Magento 2 Modules
4 1x Magento 2 Module
4 Webroot: 1,1 GB
4 Database: 82 MB
4 Total with Log-Data: ~1.200 MB
4 200 planned Modules: 240 GB
netz98 GmbH - Christian Münch / @cmuench 7
8
Simple CI Workflow
4 Configuration only with a single file
4 .gitlab-ci.yml
netz98 GmbH - Christian Münch / @cmuench 9
Simple Job Example
job1:
script: ls -l
netz98 GmbH - Christian Münch / @cmuench 10
Multiple Script Commands
job1:
script:
- cd myproject
- vendor/bin/phpunit
netz98 GmbH - Christian Münch / @cmuench 11
Multi Stages
stages:
- test
- deploy
run_tests:
stage: test
script: php run-some-tests.php
deploy_to_server:
stage: deploy
script: php mageDeploy2.php
netz98 GmbH - Christian Münch / @cmuench 12
 Pipeline View
netz98 GmbH - Christian Münch / @cmuench 13
Same Jobs in Docker Containers
stages:
- test
- deploy
image: php:5.6
run_tests:
stage: test
script: php run-some-tests.php
deploy_to_server:
stage: deploy
image: php:7.0
script: php mageDeploy2.php
netz98 GmbH - Christian Münch / @cmuench 14
Install Special Tools
before_script:
- apt-get install swaks
job1:
script:
- swaks --from foo@example.com --to bar@example.com
- ...
netz98 GmbH - Christian Münch / @cmuench 15
Artifacts
4 Runner sends generated artifacts to Gitlab Instance
via REST Api.
job1:
script: php generate_artifact.php
artifacts:
when: on_success
paths:
- path_to_artifact/
expire_in: 1 week
netz98 GmbH - Christian Münch / @cmuench 16
Sphinx Doc
stages:
- build
documentation_pdf:
stage: build
image: n98-sphinx-doc:1.4.6
script:
- cd doc
- make clean
- make latexpdf
retry: 2
only:
- master
artifacts:
when: on_success
paths:
- doc/_build/latex/*.pdf
expire_in: 1 week
netz98 GmbH - Christian Münch / @cmuench 17
Gitlab-Runner / Docker Execution
netz98 GmbH - Christian Münch / @cmuench 18
Test Build-Pipeline
Locally
brew install gitlab-runner # or use apt-get, yum, ....
cd <project-with-gitlab-ci-file>
gitlab-runner exec docker <job_in_gitlab_ci_config>
netz98 GmbH - Christian Münch / @cmuench 19
Docker Image Hierarchy
netz98 GmbH - Christian Münch / @cmuench 20
Image-Generation with CI-Pipeline
netz98 GmbH - Christian Münch / @cmuench 21
Technical Setup (Current) -> Unix Socket
Mounting
netz98 GmbH - Christian Münch / @cmuench 22
Technical Setup (Future) -> Docker in Docker
netz98 GmbH - Christian Münch / @cmuench 23
Testing Examples
24
Testing PHP Library
stages:
- test
ci_run_php_5:
stage: test
image: n98-php:5.6
script:
- composer install --prefer-dist
- bash build/gitlab/php_lint.sh
- vendor/bin/robo run:ci
coverage: '/^s*Lines:s*d+.d+%/'
artifacts:
when: on_success
paths:
- build/output/phpunit
expire_in: 1 week
netz98 GmbH - Christian Münch / @cmuench 25
Cache Vendor Directory
cache:
paths:
- vendor
untracked: true
netz98 GmbH - Christian Münch / @cmuench 26
XDebug
4 Installed but disabled by default
4 Activate during runtime
install_special_project_tools:
stage: setup
image: n98-php:7.0
script:
- docker-php-ext-enable xdebug
- vendor/bin/phpunit --colors --debug --coverage-html coverage-html-report --coverage-text
- coverage: '/^s*Lines:s*d+.d+%/'
netz98 GmbH - Christian Münch / @cmuench 27
Testing M2 Modules
stages:
- test
before_script:
- mysql_start
.job_template: &job_definition
script:
- install-module
- cd $MAGENTO_ROOT
- vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist $CI_PROJECT_DIR/src/Test
EE-2.1:
image: n98-magento-ee:2.1
<<: *job_definition
EE-2.2:
image: n98-magento-ee:2.2
<<: *job_definition
netz98 GmbH - Christian Münch / @cmuench 28
Test M2 Theme
stages:
- test
before_script:
- mysql_start
.job_template: &job_definition
script:
- install-theme
CE-2.2:
image: n98-magento-ce:2.2
<<: *job_definition
EE-2.2:
image: n98-magento-ee:2.2
<<: *job_definition
netz98 GmbH - Christian Münch / @cmuench 29
Gitflow Support
Branches
4 Develop branch contains the
"bleeding edge"
4 Test only against latest
supported Magento versions.
4 Every Major Break -> New
Support Branch
netz98 GmbH - Christian Münch / @cmuench 30
Gitflow Support
Branches
4 One or more support branches
are available for older Magento
versions.
4 Needs backports for bugfixes,
features
4 Allows different CI configs
4 Needs strict Semantic
netz98 GmbH - Christian Münch / @cmuench 31
netz98 Gitlab CI Status
✔ PHP Images
✔ Magento Images
✔ Ansible, Sphinx-Doc Images, ...
✔ Git Mirror Sync
✔ Test PHP Libraries
✔ Test Magento 1 Modules
✔ Test Magento 2 Modules
◻ Project Builds (with docker-compose support)
◻ Deployments with specific versions (prototype available)
netz98 GmbH - Christian Münch / @cmuench 32
Links
4 https://store.fooman.co.nz/blog/harnessing-the-power-of-
composer-in-magento-2.html
4 https://docs.gitlab.com/ee/ci/docker/usingdockerbuild.html
4 https://media.ccc.de/v/froscon2017-1948-gitlab-
ciunddocker_registry
4 https://github.com/oleg-fiksel/SettingupGitLab-
CIundDocker_Registry
netz98 GmbH - Christian Münch / @cmuench 33

Jenkins to Gitlab - Intelligent Build-Pipelines

  • 1.
    Intelligent Build Pipelines fromJenkins to Gitlab netz98 GmbH - Christian Münch / @cmuench 1
  • 2.
  • 3.
    Jenkins Job List netz98GmbH - Christian Münch / @cmuench 3
  • 4.
    Jenkins Job netz98 GmbH- Christian Münch / @cmuench 4
  • 5.
    Current Jenkins Setup 41 Job for every Magento Module (sometimes two CE/EE) 4 1 Magento Installation for every Magento Module 4 1 Database for every Magento Module 4 1 extra database for Integration tests 4 Manually compiled PHP versions. 4 Software is directly installed on host 4 Only few commits in most M1 repos netz98 GmbH - Christian Münch / @cmuench 5
  • 6.
    Disk Space! ->Magento 1 Modules 4 1x Magento 1 Module 4 Webroot: 175 MB 4 Database: 62 MB 4 Total with Log-Data: ~200 MB 4 50x Magento 1 Module -> 10 GB netz98 GmbH - Christian Münch / @cmuench 6
  • 7.
    Disk Space! ->Magento 2 Modules 4 1x Magento 2 Module 4 Webroot: 1,1 GB 4 Database: 82 MB 4 Total with Log-Data: ~1.200 MB 4 200 planned Modules: 240 GB netz98 GmbH - Christian Münch / @cmuench 7
  • 8.
  • 9.
    Simple CI Workflow 4Configuration only with a single file 4 .gitlab-ci.yml netz98 GmbH - Christian Münch / @cmuench 9
  • 10.
    Simple Job Example job1: script:ls -l netz98 GmbH - Christian Münch / @cmuench 10
  • 11.
    Multiple Script Commands job1: script: -cd myproject - vendor/bin/phpunit netz98 GmbH - Christian Münch / @cmuench 11
  • 12.
    Multi Stages stages: - test -deploy run_tests: stage: test script: php run-some-tests.php deploy_to_server: stage: deploy script: php mageDeploy2.php netz98 GmbH - Christian Münch / @cmuench 12
  • 13.
     Pipeline View netz98 GmbH- Christian Münch / @cmuench 13
  • 14.
    Same Jobs inDocker Containers stages: - test - deploy image: php:5.6 run_tests: stage: test script: php run-some-tests.php deploy_to_server: stage: deploy image: php:7.0 script: php mageDeploy2.php netz98 GmbH - Christian Münch / @cmuench 14
  • 15.
    Install Special Tools before_script: -apt-get install swaks job1: script: - swaks --from foo@example.com --to bar@example.com - ... netz98 GmbH - Christian Münch / @cmuench 15
  • 16.
    Artifacts 4 Runner sendsgenerated artifacts to Gitlab Instance via REST Api. job1: script: php generate_artifact.php artifacts: when: on_success paths: - path_to_artifact/ expire_in: 1 week netz98 GmbH - Christian Münch / @cmuench 16
  • 17.
    Sphinx Doc stages: - build documentation_pdf: stage:build image: n98-sphinx-doc:1.4.6 script: - cd doc - make clean - make latexpdf retry: 2 only: - master artifacts: when: on_success paths: - doc/_build/latex/*.pdf expire_in: 1 week netz98 GmbH - Christian Münch / @cmuench 17
  • 18.
    Gitlab-Runner / DockerExecution netz98 GmbH - Christian Münch / @cmuench 18
  • 19.
    Test Build-Pipeline Locally brew installgitlab-runner # or use apt-get, yum, .... cd <project-with-gitlab-ci-file> gitlab-runner exec docker <job_in_gitlab_ci_config> netz98 GmbH - Christian Münch / @cmuench 19
  • 20.
    Docker Image Hierarchy netz98GmbH - Christian Münch / @cmuench 20
  • 21.
    Image-Generation with CI-Pipeline netz98GmbH - Christian Münch / @cmuench 21
  • 22.
    Technical Setup (Current)-> Unix Socket Mounting netz98 GmbH - Christian Münch / @cmuench 22
  • 23.
    Technical Setup (Future)-> Docker in Docker netz98 GmbH - Christian Münch / @cmuench 23
  • 24.
  • 25.
    Testing PHP Library stages: -test ci_run_php_5: stage: test image: n98-php:5.6 script: - composer install --prefer-dist - bash build/gitlab/php_lint.sh - vendor/bin/robo run:ci coverage: '/^s*Lines:s*d+.d+%/' artifacts: when: on_success paths: - build/output/phpunit expire_in: 1 week netz98 GmbH - Christian Münch / @cmuench 25
  • 26.
    Cache Vendor Directory cache: paths: -vendor untracked: true netz98 GmbH - Christian Münch / @cmuench 26
  • 27.
    XDebug 4 Installed butdisabled by default 4 Activate during runtime install_special_project_tools: stage: setup image: n98-php:7.0 script: - docker-php-ext-enable xdebug - vendor/bin/phpunit --colors --debug --coverage-html coverage-html-report --coverage-text - coverage: '/^s*Lines:s*d+.d+%/' netz98 GmbH - Christian Münch / @cmuench 27
  • 28.
    Testing M2 Modules stages: -test before_script: - mysql_start .job_template: &job_definition script: - install-module - cd $MAGENTO_ROOT - vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist $CI_PROJECT_DIR/src/Test EE-2.1: image: n98-magento-ee:2.1 <<: *job_definition EE-2.2: image: n98-magento-ee:2.2 <<: *job_definition netz98 GmbH - Christian Münch / @cmuench 28
  • 29.
    Test M2 Theme stages: -test before_script: - mysql_start .job_template: &job_definition script: - install-theme CE-2.2: image: n98-magento-ce:2.2 <<: *job_definition EE-2.2: image: n98-magento-ee:2.2 <<: *job_definition netz98 GmbH - Christian Münch / @cmuench 29
  • 30.
    Gitflow Support Branches 4 Developbranch contains the "bleeding edge" 4 Test only against latest supported Magento versions. 4 Every Major Break -> New Support Branch netz98 GmbH - Christian Münch / @cmuench 30
  • 31.
    Gitflow Support Branches 4 Oneor more support branches are available for older Magento versions. 4 Needs backports for bugfixes, features 4 Allows different CI configs 4 Needs strict Semantic netz98 GmbH - Christian Münch / @cmuench 31
  • 32.
    netz98 Gitlab CIStatus ✔ PHP Images ✔ Magento Images ✔ Ansible, Sphinx-Doc Images, ... ✔ Git Mirror Sync ✔ Test PHP Libraries ✔ Test Magento 1 Modules ✔ Test Magento 2 Modules ◻ Project Builds (with docker-compose support) ◻ Deployments with specific versions (prototype available) netz98 GmbH - Christian Münch / @cmuench 32
  • 33.
    Links 4 https://store.fooman.co.nz/blog/harnessing-the-power-of- composer-in-magento-2.html 4 https://docs.gitlab.com/ee/ci/docker/usingdockerbuild.html 4https://media.ccc.de/v/froscon2017-1948-gitlab- ciunddocker_registry 4 https://github.com/oleg-fiksel/SettingupGitLab- CIundDocker_Registry netz98 GmbH - Christian Münch / @cmuench 33