Scripts to deploy Magento2 projects with Jenkins / CI Pipeline. This includes packaging the project and deploying it while setting all required variables for database, environment, etc.
Deploy scripts are based on the superb work of @fbrnc and AOE (https://github.com/AOEpeople/magento-deployscripts) for Magento 1
-
Whole Magento project is packaged into an build archive (project.tar.gz)
-
Generated build archive is copied to a central storage server
-
Deploy scripts are cloned for deployment on staging/production server
-
deploy.sh is executed, downloads and unpacks package.tar.gz and runs install.sh
magento2-deployscripts/deploy.sh -r /tmp/artifacts/project.tar.gz -e devbox -d -t /var/www/project/devbox/
-
install.sh sets database and environment variables
-
Cleanup of older releases
Define configuration in config/settings.csv regarding the zettr documentation
- Environment Settings
- Database updates
- XmlFile configuration
Add this package to your Magento composer.json:
"require": {
"tschifftner/magento2-deployscripts": "dev-master"
},
To use zettr with Magento2 you need to add it too (respository is required as long as the pull request is not merged)
"require": {
"aoepeople/zettr": "@dev"
},
"repositories": {
"0": {
"type": "vcs",
"url": "https://github.com/tschifftner/zettr.git"
}
},
As there is a bug within Magento you currently require also
"require": {
"tschifftner/magento2-module-tschifftner-deployhelper": "dev-master"
},
-
Update Magento2 project source code to latest version
-
Run shell commands:
bin/composer.phar update --verbose --no-ansi --no-interaction --prefer-source
vendor/tschifftner/magento2-deployscripts/build.sh -f project.tar.gz -b $BUILD_NUMBER
- Archive artefacts and/or copy to central storage like sftp or s3
Deployment for staging or production is all the same just with different variables.
- Clone deployment scripts to accessible location
git clone https://github.com/tschifftner/magento2-deployscripts.git ~/deployscripts
- Ensure scripts are executable
chmod +x ~/deployscripts/{deploy,cleanup}.sh
- Deploy build package
# e = environment (staging,production,devbox,etc)
# r = package url
# u = user
# p = password
# t = project dir
~/deployscripts/deploy.sh -e staging -r http://storageserver.com/project.tar.gz -u 'user' -p 'password' -t /var/www/project/ || exit1
- Cleanup old releases
~/deployscripts/cleanup.sh -r ~/releases/ || exit1