From dbc9f0edb9d31eb8187f2b50636e042733e93564 Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 11 Nov 2016 15:05:54 -0600 Subject: [PATCH 01/35] Added issue number to CL --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a950e3e..a0a80df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ 0.5.6 ========== -* Fixed issue where setup:di:compile failing to return an exit code caused DI compilation failures to be masked +* Fixed issue where setup:di:compile failing to return an exit code caused DI compilation failures to be masked (issue #41) 0.5.5 ========== From 3330e58237efe3c3b67bc671dc6f7eabf4110a03 Mon Sep 17 00:00:00 2001 From: Justin Pratt Date: Mon, 14 Nov 2016 23:15:15 -0900 Subject: [PATCH 02/35] fix version for deploying static files for version 2.1 as it does not have the added options of v2.1.1 --- lib/capistrano/tasks/magento.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/capistrano/tasks/magento.rake b/lib/capistrano/tasks/magento.rake index 4aee80a..ab892b9 100644 --- a/lib/capistrano/tasks/magento.rake +++ b/lib/capistrano/tasks/magento.rake @@ -270,8 +270,8 @@ namespace :magento do deploy_flags = ['javascript', 'css', 'less', 'images', 'fonts', 'html', 'misc', 'html-minify'] .join(' --no-').prepend(' --no-'); - # Magento 2.0 does not have these flags, so only way to generate secure files is to do all of them :/ - deploy_flags = nil if _magento_version <= 2.0 + # Magento 2.1 does not have these flags, so only way to generate secure files is to do all of them :/ + deploy_flags = nil if _magento_version <= 2.1 within release_path do with(https: 'on') { static_content_deploy "#{deploy_languages}#{deploy_themes}#{deploy_flags}" From 8d23f0b211ed2de6534a72c3ded549d2b78d909a Mon Sep 17 00:00:00 2001 From: David Alger Date: Thu, 17 Nov 2016 16:18:45 -0600 Subject: [PATCH 03/35] Implemented patch version check on static-content deploy-flag usage switch; also fix -t flag on 2.1.0 PR #46, issue #45 --- lib/capistrano/magento2.rb | 2 +- lib/capistrano/tasks/magento.rake | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 1aa3cf7..63cc808 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -13,7 +13,7 @@ module Capistrano module Magento2 module Helpers def magento_version - return (capture "/usr/bin/env php -f #{release_path}/bin/magento -- -V").split(' ').pop.to_f + return Gem::Version::new((capture "/usr/bin/env php -f #{release_path}/bin/magento -- -V").split(' ').pop) end def disabled_modules diff --git a/lib/capistrano/tasks/magento.rake b/lib/capistrano/tasks/magento.rake index ab892b9..14a28c9 100644 --- a/lib/capistrano/tasks/magento.rake +++ b/lib/capistrano/tasks/magento.rake @@ -11,7 +11,7 @@ include Capistrano::Magento2::Helpers include Capistrano::Magento2::Setup namespace :magento do - + namespace :cache do desc 'Flush Magento cache storage' task :flush do @@ -93,7 +93,7 @@ namespace :magento do execute :composer, "install #{composer_flags} 2>&1" - if fetch(:magento_deploy_production) and magento_version > 2.0 + if fetch(:magento_deploy_production) and magento_version >= Gem::Version.new('2.1') composer_flags += ' --no-dev' execute :composer, "install #{composer_flags} 2>&1" # removes require-dev components from prev command end @@ -246,10 +246,10 @@ namespace :magento do deploy_languages = fetch(:magento_deploy_languages).join(' ') deploy_themes = fetch(:magento_deploy_themes) - if deploy_themes.count() > 0 and _magento_version >= 2.1 + if deploy_themes.count() > 0 and _magento_version >= Gem::Version.new('2.1.1') deploy_themes = deploy_themes.join(' -t ').prepend(' -t ') elsif deploy_themes.count() > 0 - warn "\e[0;31mWarning: Magento 2.0 does not support :magento_deploy_themes setting (ignoring value)\e[0m" + warn "\e[0;31mWarning: the :magento_deploy_themes setting is only supported in Magento 2.1.1 and later\e[0m" deploy_themes = nil else deploy_themes = nil @@ -270,8 +270,8 @@ namespace :magento do deploy_flags = ['javascript', 'css', 'less', 'images', 'fonts', 'html', 'misc', 'html-minify'] .join(' --no-').prepend(' --no-'); - # Magento 2.1 does not have these flags, so only way to generate secure files is to do all of them :/ - deploy_flags = nil if _magento_version <= 2.1 + # Magento 2.1.0 and earlier lack support for these flags, so generation of secure files requires full re-run + deploy_flags = nil if _magento_version <= Gem::Version.new('2.1.0') within release_path do with(https: 'on') { static_content_deploy "#{deploy_languages}#{deploy_themes}#{deploy_flags}" From 3ee2f9a2666b686bae9465fb97a8ad7df63fc1af Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 18 Nov 2016 11:47:15 -0600 Subject: [PATCH 04/35] Updated README and CL --- CHANGELOG.md | 5 +++++ README.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a80df..0b92fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Capistrano::Magento2 Change Log +UNRELEASED +========== + +* Fixed failing deploys for Magento 2.1.0 caused by improper version checks on flags added in version 2.1.1 (issue #45) + 0.5.6 ========== diff --git a/README.md b/README.md index a9f8991..575d2d2 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Before you can use Capistrano to deploy, you must configure the `config/deploy.r | `:magento_deploy_setup_role` | `:all` | Role from which primary host is chosen to run things like setup:upgrade on | `:magento_deploy_cache_shared` | `true` | If true, cache operations are restricted to the primary node in setup role | `:magento_deploy_languages` | `['en_US']` | Array of languages passed to static content deploy routine -| `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy routine (Magento 2.1+ only) +| `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy (Magento 2.1.1 and later) | `:magento_deploy_composer` | `true` | Enables composer install behaviour in the built-in deploy routine | `:magento_deploy_production` | `true` | Enables production specific DI compilation and static content generation | `:magento_deploy_maintenance` | `true` | Enables use of maintenance mode while magento:setup:upgrade runs From d5c98104845e28da4e33fbfdda971594e0244ac1 Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 18 Nov 2016 13:21:16 -0600 Subject: [PATCH 05/35] Add pipefail option to static-content deploy command so error codes will bubble up Fixes #44, Closes #47 --- lib/capistrano/magento2.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 63cc808..3f7462b 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -33,10 +33,18 @@ def cache_hosts module Setup def static_content_deploy params + # Setting pipefail causes the console exit codes introduced in Magento 2.1.1 to bubble up and halt execution + # as is normally expected. Versions which do not return exit codes will fall back on the far less reliable + # error checks we're doing on the command output + SSHKit.config.command_map.prefix[:magento].push("set -o pipefail;") + output = capture :magento, "setup:static-content:deploy #{params} | stdbuf -o0 tr -d .", verbosity: Logger::INFO + # Clear the pipefail option from list of prefixes so it won't affect other commands + SSHKit.config.command_map.prefix[:magento].pop + if not output.to_s.include? 'New version of deployed files' raise Exception, "\e[0;31mFailed to compile static assets\e[0m" end From 13ed98c298e4989ba2393e9b29b3055b636d7d42 Mon Sep 17 00:00:00 2001 From: David Alger Date: Tue, 22 Nov 2016 17:17:34 -0600 Subject: [PATCH 06/35] Added code comment regarding version static content deploy error checking --- lib/capistrano/magento2.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 3f7462b..37e6174 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -45,6 +45,7 @@ def static_content_deploy params # Clear the pipefail option from list of prefixes so it won't affect other commands SSHKit.config.command_map.prefix[:magento].pop + # String based error checking is here to catch errors in Magento 2.1.0 and earlier if not output.to_s.include? 'New version of deployed files' raise Exception, "\e[0;31mFailed to compile static assets\e[0m" end From 8182bc49f7abf351febdf6f66cc1c8aed894835a Mon Sep 17 00:00:00 2001 From: David Alger Date: Tue, 22 Nov 2016 17:18:36 -0600 Subject: [PATCH 07/35] Updated CL --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b92fab..c4b69e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ UNRELEASED ========== * Fixed failing deploys for Magento 2.1.0 caused by improper version checks on flags added in version 2.1.1 (issue #45) +* Fixed failure to detect error codes Magento 2.1.1 returns on a failed static-content deploy job (issue #44) 0.5.6 ========== From 70a7d38eba81b5f2612ad817107e4eb64adc1a04 Mon Sep 17 00:00:00 2001 From: David Alger Date: Tue, 22 Nov 2016 17:20:03 -0600 Subject: [PATCH 08/35] Version bump --- CHANGELOG.md | 2 +- lib/capistrano/magento2/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4b69e8..ae13676 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Capistrano::Magento2 Change Log -UNRELEASED +0.5.7 ========== * Fixed failing deploys for Magento 2.1.0 caused by improper version checks on flags added in version 2.1.1 (issue #45) diff --git a/lib/capistrano/magento2/version.rb b/lib/capistrano/magento2/version.rb index 4ea010a..3f806c9 100644 --- a/lib/capistrano/magento2/version.rb +++ b/lib/capistrano/magento2/version.rb @@ -9,6 +9,6 @@ module Capistrano module Magento2 - VERSION = '0.5.6' + VERSION = '0.5.7' end end From ee6b2e3cccadf67e098eee5cec3358b984a1280b Mon Sep 17 00:00:00 2001 From: David Alger Date: Mon, 28 Nov 2016 17:26:59 -0600 Subject: [PATCH 09/35] Correct erroneous issue in command map handling which completely broke static content deployment in 0.5.7 closes #51, closes #50 --- CHANGELOG.md | 5 +++++ lib/capistrano/magento2.rb | 7 ++++--- lib/capistrano/magento2/version.rb | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae13676..e8ac1bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Capistrano::Magento2 Change Log +0.5.8 +========== + +* Fixed critical failure due to command map being broken in v0.5.7 updates + 0.5.7 ========== diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 37e6174..8404ca3 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -36,14 +36,15 @@ def static_content_deploy params # Setting pipefail causes the console exit codes introduced in Magento 2.1.1 to bubble up and halt execution # as is normally expected. Versions which do not return exit codes will fall back on the far less reliable # error checks we're doing on the command output - SSHKit.config.command_map.prefix[:magento].push("set -o pipefail;") + magento_command = SSHKit.config.command_map[:magento] + SSHKit.config.command_map[:magento] = "set -o pipefail; #{magento_command}" output = capture :magento, "setup:static-content:deploy #{params} | stdbuf -o0 tr -d .", verbosity: Logger::INFO - # Clear the pipefail option from list of prefixes so it won't affect other commands - SSHKit.config.command_map.prefix[:magento].pop + # Reset the command map without our prefix, removing pipefail option so it won't affect other commands + SSHKit.config.command_map[:magento] = magento_command # String based error checking is here to catch errors in Magento 2.1.0 and earlier if not output.to_s.include? 'New version of deployed files' diff --git a/lib/capistrano/magento2/version.rb b/lib/capistrano/magento2/version.rb index 3f806c9..b5f825d 100644 --- a/lib/capistrano/magento2/version.rb +++ b/lib/capistrano/magento2/version.rb @@ -9,6 +9,6 @@ module Capistrano module Magento2 - VERSION = '0.5.7' + VERSION = '0.5.8' end end From a30d7e93c2384c1d2caee001b43ed9b25d4976f4 Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 30 Nov 2016 15:55:55 -0600 Subject: [PATCH 10/35] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8ac1bc..16dae7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,11 @@ 0.5.8 ========== -* Fixed critical failure due to command map being broken in v0.5.7 updates +* Fixed critical failure due to command map being broken in v0.5.7 updates (issue #50, issue #51) 0.5.7 ========== +_Note: This release was yanked from RubyGems due to a critical failure in the deploy routine._ * Fixed failing deploys for Magento 2.1.0 caused by improper version checks on flags added in version 2.1.1 (issue #45) * Fixed failure to detect error codes Magento 2.1.1 returns on a failed static-content deploy job (issue #44) From 69858877631daf893e4849639697fe25bc971a59 Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 2 Dec 2016 14:48:38 -0600 Subject: [PATCH 11/35] =?UTF-8?q?Corrected=20the=20persistence=20of=20the?= =?UTF-8?q?=20pipe=20fail=20option=20(shouldn=E2=80=99t=20persist=20but=20?= =?UTF-8?q?it=20was=20due=20to=20var=20assignment=20by=20reference)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ lib/capistrano/magento2.rb | 25 +++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16dae7f..8b791e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Capistrano::Magento2 Change Log +========== + +* Fixed bug causing pipefail option to persist after `Capistrano::Magento2::Setup.static_content_deploy` is called + 0.5.8 ========== diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 8404ca3..07d910b 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -29,24 +29,29 @@ def disabled_modules def cache_hosts return fetch(:magento_deploy_cache_shared) ? (primary fetch :magento_deploy_setup_role) : (release_roles :all) end + + # Set pipefail allowing console exit codes in Magento 2.1.1 and later to halt execution when using pipes + def Helpers.set_pipefail + @@pipefail_less = SSHKit.config.command_map[:magento].dup + SSHKit.config.command_map[:magento] = "set -o pipefail; #{@@pipefail_less}" + end + + # Reset the command map without prefix, removing pipefail option so it won't affect other commands + def Helpers.unset_pipefail + SSHKit.config.command_map[:magento] = @@pipefail_less + end end module Setup def static_content_deploy params - # Setting pipefail causes the console exit codes introduced in Magento 2.1.1 to bubble up and halt execution - # as is normally expected. Versions which do not return exit codes will fall back on the far less reliable - # error checks we're doing on the command output - magento_command = SSHKit.config.command_map[:magento] - SSHKit.config.command_map[:magento] = "set -o pipefail; #{magento_command}" - + Helpers.set_pipefail output = capture :magento, "setup:static-content:deploy #{params} | stdbuf -o0 tr -d .", verbosity: Logger::INFO + Helpers.unset_pipefail - # Reset the command map without our prefix, removing pipefail option so it won't affect other commands - SSHKit.config.command_map[:magento] = magento_command - - # String based error checking is here to catch errors in Magento 2.1.0 and earlier + # String based error checking is here to catch errors in Magento 2.1.0 and earlier; later versions will exit + # immediately when a console exit code is retruned, never evaluating this code. if not output.to_s.include? 'New version of deployed files' raise Exception, "\e[0;31mFailed to compile static assets\e[0m" end From 625a4ed059bf82c36baf47d2b18c170016959abb Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 2 Dec 2016 15:10:08 -0600 Subject: [PATCH 12/35] Updated set_pipefail to not double the set calls resulting in it hanging around on multi-host deploys --- lib/capistrano/magento2.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 07d910b..9e7de56 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -32,8 +32,10 @@ def cache_hosts # Set pipefail allowing console exit codes in Magento 2.1.1 and later to halt execution when using pipes def Helpers.set_pipefail - @@pipefail_less = SSHKit.config.command_map[:magento].dup - SSHKit.config.command_map[:magento] = "set -o pipefail; #{@@pipefail_less}" + if not SSHKit.config.command_map[:magento].include? 'set -o pipefail' # avoids trouble on multi-host deploys + @@pipefail_less = SSHKit.config.command_map[:magento].dup + SSHKit.config.command_map[:magento] = "set -o pipefail; #{@@pipefail_less}" + end end # Reset the command map without prefix, removing pipefail option so it won't affect other commands @@ -41,7 +43,7 @@ def Helpers.unset_pipefail SSHKit.config.command_map[:magento] = @@pipefail_less end end - + module Setup def static_content_deploy params Helpers.set_pipefail From d6fe046755ebc13e2153afe09935323da5cc0240 Mon Sep 17 00:00:00 2001 From: Erik Hansen Date: Thu, 22 Dec 2016 21:18:03 -0600 Subject: [PATCH 13/35] Update readme for Capistrano 3.7 See https://github.com/capistrano/capistrano/blob/master/UPGRADING-3.7.md for details --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 575d2d2..1e4074a 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,10 @@ _Note: By default, Capistrano creates "staging" and "production" stages. If you # Load Magento deployment tasks require 'capistrano/magento2/deploy' + # Load Git plugin + require "capistrano/scm/git" + install_plugin Capistrano::SCM::Git + # Load custom tasks from `lib/capistrano/tasks` if you have any defined Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } ``` From 4e1e951a5978fddaa9ca64983e8e8f7330db9629 Mon Sep 17 00:00:00 2001 From: David Alger Date: Thu, 26 Jan 2017 12:13:00 -0600 Subject: [PATCH 14/35] Updated default linked_dirs to link sitemaps, dropped sitemap.xml --- lib/capistrano/magento2/defaults.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/capistrano/magento2/defaults.rb b/lib/capistrano/magento2/defaults.rb index aed0335..fcdb0b8 100644 --- a/lib/capistrano/magento2/defaults.rb +++ b/lib/capistrano/magento2/defaults.rb @@ -10,19 +10,18 @@ set :linked_files, fetch(:linked_files, []).push( 'app/etc/env.php', 'var/.setup_cronjob_status', - 'var/.update_cronjob_status', - 'pub/sitemap.xml' + 'var/.update_cronjob_status' ) set :linked_files_touch, fetch(:linked_files_touch, []).push( 'app/etc/env.php', 'var/.setup_cronjob_status', - 'var/.update_cronjob_status', - 'pub/sitemap.xml' + 'var/.update_cronjob_status' ) set :linked_dirs, fetch(:linked_dirs, []).push( - 'pub/media', + 'pub/media', + 'pub/sitemaps', 'var/backups', 'var/composer_home', 'var/importexport', From a1718112f552738cd45733ce99ede1f2cd8a494d Mon Sep 17 00:00:00 2001 From: David Alger Date: Thu, 26 Jan 2017 12:15:18 -0600 Subject: [PATCH 15/35] Updated README to reflect default changes and add append usage --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1e4074a..a7c3cce 100644 --- a/README.md +++ b/README.md @@ -147,12 +147,12 @@ For the sake of simplicity in new project setups `:linked_dirs` and `:linked_fil set :linked_files, [ 'app/etc/env.php', 'var/.setup_cronjob_status', - 'var/.update_cronjob_status', - 'pub/sitemap.xml' + 'var/.update_cronjob_status' ] set :linked_dirs, [ - 'pub/media', + 'pub/media', + 'pub/sitemaps', 'var/backups', 'var/composer_home', 'var/importexport', @@ -163,7 +163,11 @@ set :linked_dirs, [ ] ``` -If you would like to customize the linked files or directories for your project, you can copy either one or both of the above arrays into the `config/deploy.rb` or `config/deploy/*.rb` files and tweak them to fit your project's needs. +If you would like to customize the linked files or directories for your project, you can copy either one or both of the above arrays into the `config/deploy.rb` or `config/deploy/*.rb` files and tweak them to fit your project's needs. Alternatively, you can add a single linked dir (or file) using `append` like this: + +```ruby +append :linked_dirs, 'path/to/link' +``` ### Magento 2 Deploy Routine From 1cba9bd33064440fe4ff4562e1df5a42a5c372dc Mon Sep 17 00:00:00 2001 From: Thibaud QUINTARD Date: Mon, 30 Jan 2017 23:19:53 +0100 Subject: [PATCH 16/35] Add composer magento auth config --- lib/capistrano/magento2/defaults.rb | 4 ++++ lib/capistrano/tasks/magento.rake | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/capistrano/magento2/defaults.rb b/lib/capistrano/magento2/defaults.rb index aed0335..bb9544a 100644 --- a/lib/capistrano/magento2/defaults.rb +++ b/lib/capistrano/magento2/defaults.rb @@ -32,6 +32,10 @@ 'var/tmp' ) +# deploy auth defaults +set :magento_auth_public_key, fetch(:magento_auth_public_key, '') +set :magento_auth_private_key, fetch(:magento_auth_private_key, '') + # deploy permissions defaults set :magento_deploy_chmod_d, fetch(:magento_deploy_chmod_d, '2770') set :magento_deploy_chmod_f, fetch(:magento_deploy_chmod_f, '0660') diff --git a/lib/capistrano/tasks/magento.rake b/lib/capistrano/tasks/magento.rake index 14a28c9..63a8f7d 100644 --- a/lib/capistrano/tasks/magento.rake +++ b/lib/capistrano/tasks/magento.rake @@ -91,6 +91,11 @@ namespace :magento do composer_flags += ' --optimize-autoloader' end + if fetch(:magento_auth_public_key).to_s != '' and fetch(:magento_auth_private_key).to_s != '' + execute :composer, :config, "http-basic.repo.magento.com", + fetch(:magento_auth_public_key), fetch(:magento_auth_private_key), "2>&1" + end + execute :composer, "install #{composer_flags} 2>&1" if fetch(:magento_deploy_production) and magento_version >= Gem::Version.new('2.1') From 4ef207e60b5271704f772dfbc60c9a00b3074378 Mon Sep 17 00:00:00 2001 From: David Alger Date: Tue, 7 Feb 2017 14:08:37 -0600 Subject: [PATCH 17/35] Prepare for version 0.5.9 release --- CHANGELOG.md | 4 ++++ lib/capistrano/magento2/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b791e6..7610539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ # Capistrano::Magento2 Change Log +0.5.9 ========== +* Updated README with Capistrano 3.7 setup information +* Updated `linked_dirs` to link `pub/sitemaps` by default in similar fashion to the Magento1 deployment gem +* Updated README with guidance on adding a path to the list of `linked_dirs` without copying the entire configuration forward * Fixed bug causing pipefail option to persist after `Capistrano::Magento2::Setup.static_content_deploy` is called 0.5.8 diff --git a/lib/capistrano/magento2/version.rb b/lib/capistrano/magento2/version.rb index b5f825d..666c92a 100644 --- a/lib/capistrano/magento2/version.rb +++ b/lib/capistrano/magento2/version.rb @@ -9,6 +9,6 @@ module Capistrano module Magento2 - VERSION = '0.5.8' + VERSION = '0.5.9' end end From 32a110f231270422576cf0b855c361d1b17e3347 Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 15 Feb 2017 10:19:58 -0600 Subject: [PATCH 18/35] Remove terminal-notifier dependency Issue #19 --- CHANGELOG.md | 5 +++++ README.md | 19 ++++++++++++++----- capistrano-magento2.gemspec | 3 --- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7610539..bf0466d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Capistrano::Magento2 Change Log +UNRELEASED +========== + +* Updated README to reflect removing the `terminal-notifier` gem as a hard dependency (issue #19) + 0.5.9 ========== diff --git a/README.md b/README.md index a7c3cce..f63a5d1 100644 --- a/README.md +++ b/README.md @@ -208,18 +208,27 @@ All Magento 2 tasks used by the built-in `deploy.rake` file as well as some addi | magento:setup:static-content:deploy | Deploys static view files | | magento:setup:upgrade | Run the Magento upgrade process | -## Terminal Notifier on OS X -This gem specifies [terminal-notifier](https://rubygems.org/gems/terminal-notifier) as a dependency in order to support notifications on OS X via an optional include. To use the built-in notifications, add the following line to your `Capfile`: +## Optional 3rd-Party Gem Configuration Includes + +### Terminal Notifier + +This gem configuration include adds notifications via the [terminal-notifier](https://rubygems.org/gems/terminal-notifier) gem. To configure the notifications, simply add the following line to your `Capfile`: ```ruby require 'capistrano/magento2/notifier' ``` -## Pending Changes +**Notice:** The `terminal-notifier` gem is currently macOS specific and thus can not be used on generic *nix environments. Because this gem has been known to cause ruby stability issues on certain non-macOS environments, it is not specified as a hard requirement in this gem's gemspec. When using this functionality, it is expected the gem either be already present on your working environment or be added to your project's `Gemfile`: + +```ruby +gem 'terminal-notifier' +``` + +### Pending Changes -This gem specifies [capistrano-pending](https://rubygems.org/gems/capistrano-pending) as a dependency and adds some (optional) custom functionality on top of that gem: Any time the `deploy` command is run, a one line summary of git commits that will be deployed will be displayed. If the server(s) you are deploying to already have the latest changes, you will be warned of this and a prompt will appear confirming that you want to continue deploying. +This gem configuration include specifies [capistrano-pending](https://rubygems.org/gems/capistrano-pending) as a dependency and adds some (optional) custom functionality on top of that gem: Any time the `deploy` command is run, a one line summary of git commits that will be deployed will be displayed. If the server(s) you are deploying to already have the latest changes, you will be warned of this and a prompt will appear confirming that you want to continue deploying. -To add the `capistrano-pending` gem and additional functionality to you project, add the following line to your `Capfile`: +To add the `capistrano-pending` gem's enhanced functionality to you project, add the following line to your `Capfile`: ```ruby require 'capistrano/magento2/pending' diff --git a/capistrano-magento2.gemspec b/capistrano-magento2.gemspec index b52794b..cae1a87 100644 --- a/capistrano-magento2.gemspec +++ b/capistrano-magento2.gemspec @@ -28,9 +28,6 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_dependency 'capistrano', '~> 3.1' - - # TODO explore removing these from gemspec per issue #19 - spec.add_dependency 'terminal-notifier', '~> 1.6' spec.add_dependency 'capistrano-pending', '~> 0.1' spec.add_development_dependency 'bundler', '~> 1.7' From 96b1c054cd9d12f05688a516e77ffbcb85cecae9 Mon Sep 17 00:00:00 2001 From: David Alger Date: Thu, 23 Feb 2017 13:28:12 -0600 Subject: [PATCH 19/35] Fixed inability to set PATH in capistrano configuration vs `.bashrc` file Resolves #62 --- CHANGELOG.md | 1 + lib/capistrano/magento2.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf0466d..15b9942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ UNRELEASED ========== +* Fixed inability to set PATH in capistrano configuration vs `.bashrc` file (issue #62) * Updated README to reflect removing the `terminal-notifier` gem as a hard dependency (issue #19) 0.5.9 diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 9e7de56..8a0743f 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -13,7 +13,7 @@ module Capistrano module Magento2 module Helpers def magento_version - return Gem::Version::new((capture "/usr/bin/env php -f #{release_path}/bin/magento -- -V").split(' ').pop) + return Gem::Version::new((capture :php, "-f #{release_path}/bin/magento -- -V").split(' ').pop) end def disabled_modules From 2909052f89eba74cba8ee0422a325ba8ddd01fa2 Mon Sep 17 00:00:00 2001 From: David Alger Date: Thu, 23 Feb 2017 13:45:51 -0600 Subject: [PATCH 20/35] Set :capistrano_pending_role default to match :magento_deploy_setup_role to avoid potential incompatibilities Resolves #58 --- CHANGELOG.md | 1 + README.md | 9 +++++++++ lib/capistrano/magento2/defaults.rb | 3 +++ lib/capistrano/tasks/pending.rake | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15b9942..6317057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ UNRELEASED ========== * Fixed inability to set PATH in capistrano configuration vs `.bashrc` file (issue #62) +* Fixed potential incompatibility with `capistrano-pending` default deployment settings (issue #58) * Updated README to reflect removing the `terminal-notifier` gem as a hard dependency (issue #19) 0.5.9 diff --git a/README.md b/README.md index f63a5d1..9557cec 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,15 @@ To add the `capistrano-pending` gem's enhanced functionality to you project, add require 'capistrano/magento2/pending' ``` +In order to make the `capistrano-pending` gem fully compatible with this gem out of the box, the `:capistrano_pending_role` setting has been configured to default to the value of `:magento_deploy_setup_role`. The `capistrano-pending` gem by default looks only at the `:db` role, breaking things if a project does not have code deployed to servers under the `:db` role, as would be the case when using a server configuration similar to the following: + +```ruby +role :app, %w{ + www-data@web1 + www-data@web2 +} +``` + ## Development After checking out the repo, run `bundle install` to install dependencies. Make the necessary changes, then run `bundle exec rake install` to install a modified version of the gem on your local system. diff --git a/lib/capistrano/magento2/defaults.rb b/lib/capistrano/magento2/defaults.rb index fcdb0b8..6c2fabd 100644 --- a/lib/capistrano/magento2/defaults.rb +++ b/lib/capistrano/magento2/defaults.rb @@ -47,3 +47,6 @@ # deploy targetting defaults set :magento_deploy_setup_role, fetch(:magento_deploy_setup_role, :all) set :magento_deploy_cache_shared, fetch(:magento_deploy_cache_shared, true) + +# set capistrano-pending defaults to match this gem's expectations +set :capistrano_pending_role, fetch(:magento_deploy_setup_role) diff --git a/lib/capistrano/tasks/pending.rake b/lib/capistrano/tasks/pending.rake index 3eca6ee..485259d 100644 --- a/lib/capistrano/tasks/pending.rake +++ b/lib/capistrano/tasks/pending.rake @@ -16,7 +16,7 @@ namespace :deploy do # changes and/or warn that there is nothing to deploy namespace :pending do task :check_changes do - on primary fetch(:magento_deploy_setup_role) do + on primary fetch(:capistrano_pending_role) do # check for pending changes only if REVISION file exists to prevent error if test "[ -f #{current_path}/REVISION ]" invoke 'deploy:pending:setup' From 4bfbd9bf2ff3bbc89ea17fb756a1d9ca60cd2980 Mon Sep 17 00:00:00 2001 From: David Alger Date: Thu, 23 Feb 2017 20:16:39 -0600 Subject: [PATCH 21/35] Added full-featured pending changes logging - removed capistrano-pending gem as a dependency - multi-node pending change reporting is now supported - users only warned about deploying (by default) when no pending changes are found on any node - refs are printed in a user-friendly symbolic format now - when target is ahead of deployed revision, user is warned about possibly going backwards in time and the log shown is a reverse log showing commits between current and commit being deployed (as is when deploying forward) Issue #58 --- capistrano-magento2.gemspec | 1 - lib/capistrano/magento2/defaults.rb | 9 +++- lib/capistrano/magento2/pending.rb | 75 +++++++++++++++++------------ lib/capistrano/tasks/pending.rake | 67 +++++++++++++++++--------- 4 files changed, 94 insertions(+), 58 deletions(-) diff --git a/capistrano-magento2.gemspec b/capistrano-magento2.gemspec index cae1a87..4f543b9 100644 --- a/capistrano-magento2.gemspec +++ b/capistrano-magento2.gemspec @@ -28,7 +28,6 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_dependency 'capistrano', '~> 3.1' - spec.add_dependency 'capistrano-pending', '~> 0.1' spec.add_development_dependency 'bundler', '~> 1.7' spec.add_development_dependency 'rake', '~> 10.0' diff --git a/lib/capistrano/magento2/defaults.rb b/lib/capistrano/magento2/defaults.rb index 6c2fabd..5041563 100644 --- a/lib/capistrano/magento2/defaults.rb +++ b/lib/capistrano/magento2/defaults.rb @@ -48,5 +48,10 @@ set :magento_deploy_setup_role, fetch(:magento_deploy_setup_role, :all) set :magento_deploy_cache_shared, fetch(:magento_deploy_cache_shared, true) -# set capistrano-pending defaults to match this gem's expectations -set :capistrano_pending_role, fetch(:magento_deploy_setup_role) +# pending deploy check defaults +set :magento_deploy_pending_role, fetch(:magento_deploy_pending_role, :all) +set :magento_deploy_pending_warn, fetch(:magento_deploy_pending_warn, true) +set :magento_deploy_pending_format, fetch( + :magento_deploy_pending_format, + '--pretty="format:%C(yellow)%h %Cblue%>(12)%ad %Cgreen%<(7)%aN%Cred%d %Creset%s"' +) diff --git a/lib/capistrano/magento2/pending.rb b/lib/capistrano/magento2/pending.rb index 90606fe..a821731 100644 --- a/lib/capistrano/magento2/pending.rb +++ b/lib/capistrano/magento2/pending.rb @@ -8,46 +8,57 @@ ## require 'capistrano/deploy' -require 'capistrano/pending/scm/base' module Capistrano - module Pending - module SCM - class Git < Base - - # Enhance capistrano-pending gem's native deploy:pending:log command by updating repository and then - # showing the actual changes that will be deployed. Also changes log output to oneline for easy reading - # - # Params: - # +from+ - commit-ish to compare from - # +to+ - commit-ish to compare to - # +returnOutput+ - whether to return or print the output - # - def log(from, to, returnOutput=false) + module Magento2 + module Pending + def ensure_revision inform_user = false + if test "[ -f #{current_path}/REVISION ]" + yield + elsif inform_user + warn "\e[0;31mSkipping pending changes check on #{host} (no REVISION file found)\e[0m" + end + end + + def from_rev + within current_path do + current_revision = capture(:cat, "REVISION") + run_locally do - execute :git, :fetch, :origin # update repository to ensure accuracy of pending changes report + return capture(:git, "name-rev --always --name-only #{current_revision}") # find symbolic name for ref + end + end + end - # Since the :branch to deploy from may be behind the upstream branch, get name of upstream branch - # and use it for comparison. We are using the test command in case the :branch is set to a specific - # commit hash, in which case there is no upstream branch. + def to_rev + run_locally do + to = fetch(:branch) - if test(:git, 'rev-parse', '--abbrev-ref', '--symbolic-full-name', to + '@{u}') - to = capture(:git, 'rev-parse', '--abbrev-ref', '--symbolic-full-name', to + '@{u}') - end + # get target branch upstream if there is one + if test(:git, "rev-parse --abbrev-ref --symbolic-full-name #{to}@{u}") + to = capture(:git, "rev-parse --abbrev-ref --symbolic-full-name #{to}@{u}") + end + + # find symbolic name for revision + to = capture(:git, "name-rev --always --name-only #{to}") + end + end - output = capture( - :git, - :log, - "#{from}..#{to}", - '--pretty="format:%C(yellow)%h %Cblue%>(12)%ad %Cgreen%<(7)%aN%Cred%d %Creset%s"' - ) - - if returnOutput - return output - else - puts output + + def log_pending(from, to) + run_locally do + output = capture :git, :log, "#{from}..#{to}", fetch(:magento_deploy_pending_format) + + if output.to_s.strip.empty? + output = capture :git, :log, "#{to}..#{from}", fetch(:magento_deploy_pending_format) + if not output.to_s.strip.empty? + output += "\n\e[0;31mWarning: It appears you may be going backwards in time with this deployment!\e[0m" end end + + output.each_line do |line| + info line + end end end end diff --git a/lib/capistrano/tasks/pending.rake b/lib/capistrano/tasks/pending.rake index 485259d..89f948f 100644 --- a/lib/capistrano/tasks/pending.rake +++ b/lib/capistrano/tasks/pending.rake @@ -7,36 +7,57 @@ # http://davidalger.com/contact/ ## -require 'capistrano-pending' +include Capistrano::Magento2::Pending + +before :deploy, 'deploy:pending:warn' -before :deploy, 'deploy:pending:check_changes' namespace :deploy do + desc "Displays a summary of commits pending deployment" + task :pending => 'deploy:pending:log' - # Check for pending changes on the primary node and then notify user of any incoming - # changes and/or warn that there is nothing to deploy namespace :pending do - task :check_changes do - on primary fetch(:capistrano_pending_role) do - # check for pending changes only if REVISION file exists to prevent error - if test "[ -f #{current_path}/REVISION ]" - invoke 'deploy:pending:setup' - from = fetch(:revision) - to = fetch(:branch) - - output = _scm.log(from, to, true) - if output.to_s.strip.empty? - puts "\e[0;31m No changes to deploy (from and to are the same: #{from}..#{to})" - print " Are you sure you want to continue? [y/n] \e[0m" - - proceed = STDIN.gets[0..0] rescue nil - exit unless proceed == 'y' || proceed == 'Y' - else - puts "\e[0;90m Deploying changes #{from}..#{to}:\e[0m" - output.each_line do |s| - puts " " + s + task :warn => :log do + if fetch(:magento_deploy_pending_warn) + need_warning = true + + on roles fetch(:magento_deploy_pending_role) do |host| + ensure_revision do + if from_rev != to_rev + need_warning = false end end end + + # if there is nothing to deploy on any node, prompt user for confirmation + if need_warning + print " Are you sure you want to continue? [y/n] \e[0m" + + proceed = STDIN.gets[0..0] rescue nil + exit unless proceed == 'y' || proceed == 'Y' + end + end + end + + task :log do + on roles fetch(:magento_deploy_pending_role) do |host| + ensure_revision true do + # update local repository to ensure accuracy of report + run_locally do + execute :git, :fetch, :origin + end + + # fetch current revision and revision to be deployed + from = from_rev + to = to_rev + + # output prettified log of changes between from and to commits + if from == to + info "\e[0;31mNo changes to deploy on #{host} (from and to are the same: #{from} -> #{to})\e[0m" + else + info "\e[0;90mChanges pending deployment on #{host} (#{from} -> #{to}):\e[0m" + log_pending(from, to) + end + end end end end From 51ff0c3d1d31e953dfb42c83327f7ec5a6d83de5 Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 24 Feb 2017 10:40:56 -0600 Subject: [PATCH 22/35] Updated messaging to include host name on all pending change log heading messages - also eliminated the warning being presented on a fresh deploy where no REVISION files existed Issue #58 --- lib/capistrano/magento2/pending.rb | 25 +++++---------------- lib/capistrano/tasks/pending.rake | 35 +++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/lib/capistrano/magento2/pending.rb b/lib/capistrano/magento2/pending.rb index a821731..ea955cc 100644 --- a/lib/capistrano/magento2/pending.rb +++ b/lib/capistrano/magento2/pending.rb @@ -8,6 +8,7 @@ ## require 'capistrano/deploy' +require 'capistrano/magento2' module Capistrano module Magento2 @@ -15,9 +16,11 @@ module Pending def ensure_revision inform_user = false if test "[ -f #{current_path}/REVISION ]" yield - elsif inform_user - warn "\e[0;31mSkipping pending changes check on #{host} (no REVISION file found)\e[0m" + else + warn "\e[0;31mSkipping pending changes check on #{host} (no REVISION file found)\e[0m" if inform_user + return false end + return true end def from_rev @@ -43,24 +46,6 @@ def to_rev to = capture(:git, "name-rev --always --name-only #{to}") end end - - - def log_pending(from, to) - run_locally do - output = capture :git, :log, "#{from}..#{to}", fetch(:magento_deploy_pending_format) - - if output.to_s.strip.empty? - output = capture :git, :log, "#{to}..#{from}", fetch(:magento_deploy_pending_format) - if not output.to_s.strip.empty? - output += "\n\e[0;31mWarning: It appears you may be going backwards in time with this deployment!\e[0m" - end - end - - output.each_line do |line| - info line - end - end - end end end end diff --git a/lib/capistrano/tasks/pending.rake b/lib/capistrano/tasks/pending.rake index 89f948f..5cd8fd5 100644 --- a/lib/capistrano/tasks/pending.rake +++ b/lib/capistrano/tasks/pending.rake @@ -21,14 +21,16 @@ namespace :deploy do need_warning = true on roles fetch(:magento_deploy_pending_role) do |host| - ensure_revision do - if from_rev != to_rev - need_warning = false - end + has_revision = ensure_revision do + # if any host has a change in revision, do not warn user + need_warning = false if from_rev != to_rev end + + # if a host does not have a revision, do not warn user + need_warning = false if not has_revision end - # if there is nothing to deploy on any node, prompt user for confirmation + # if there is nothing to deploy on any host, prompt user for confirmation if need_warning print " Are you sure you want to continue? [y/n] \e[0m" @@ -50,12 +52,29 @@ namespace :deploy do from = from_rev to = to_rev - # output prettified log of changes between from and to commits + # if there is nothing to deploy on this host, inform the user if from == to info "\e[0;31mNo changes to deploy on #{host} (from and to are the same: #{from} -> #{to})\e[0m" else - info "\e[0;90mChanges pending deployment on #{host} (#{from} -> #{to}):\e[0m" - log_pending(from, to) + run_locally do + header = "\e[0;90mChanges pending deployment on #{host} (#{from} -> #{to}):\e[0m\n" + + # capture log of commits between current revision and revision for deploy + output = capture :git, :log, "#{from}..#{to}", fetch(:magento_deploy_pending_format) + + # if we get no results, flip refs to look at reverse log in case of rollback deployments + if output.to_s.strip.empty? + output = capture :git, :log, "#{to}..#{from}", fetch(:magento_deploy_pending_format) + if not output.to_s.strip.empty? + header += "\e[0;31mWarning: It appears you may be going backwards in time on #{host} with this deployment!\e[0m\n" + end + end + + # write pending changes log + (header + output).each_line do |line| + info line + end + end end end end From 0a960bf1b7fe6eb29d66858179f9e52d50e8241b Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 24 Feb 2017 15:58:12 -0600 Subject: [PATCH 23/35] Updates to README for issue #58 --- README.md | 60 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9557cec..7861b5b 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ _Note: By default, Capistrano creates "staging" and "production" stages. If you # Load Magento deployment tasks require 'capistrano/magento2/deploy' + require 'capistrano/magento2/pending' # Load Git plugin require "capistrano/scm/git" @@ -179,7 +180,7 @@ To see what process the built-in routine runs, take a look at the included rake ### Web Server Root Path -Before deploying with Capistrano, you must update each of your web servers to point to a `current` directory inside of the `:deploy_to` directory. For example: `/var/www/html/current` Refer to the [Capistrano Structure](http://capistranorb.com/documentation/getting-started/structure/) to learn more about Capistrano's folder structure. +Before deploying with Capistrano, you must update each of your web servers to point to the `current` directory inside of the configured `:deploy_to` directory. For example: `/var/www/html/current/pub` Refer to the [Capistrano Structure](http://capistranorb.com/documentation/getting-started/structure/) to learn more about Capistrano's folder structure. ## Magento Specific Tasks @@ -208,39 +209,64 @@ All Magento 2 tasks used by the built-in `deploy.rake` file as well as some addi | magento:setup:static-content:deploy | Deploys static view files | | magento:setup:upgrade | Run the Magento upgrade process | -## Optional 3rd-Party Gem Configuration Includes +## Pending Changes Support -### Terminal Notifier +When the line `require 'capistrano/magento2/pending'` is included in your `Capfile` per the recommended configuration above, this gem will report changes pending deployment in an abbreviated git log style format. Here is an example: -This gem configuration include adds notifications via the [terminal-notifier](https://rubygems.org/gems/terminal-notifier) gem. To configure the notifications, simply add the following line to your `Capfile`: +``` +00:00 deploy:pending:log + 01 git fetch origin + ✔ 01 dalger@localhost 1.241s + ✔ 01 dalger@localhost 1.259s + Changes pending deployment on web1 (tags/2.1.2 -> 2.1): + f511288 Thu Feb 23 12:19:20 2017 -0600 David Alger (HEAD -> 2.1, tag: 2.1.4, origin/2.1) Magento 2.1.4 + 7fb219c Thu Feb 23 12:17:11 2017 -0600 David Alger (tag: 2.1.3) Magento 2.1.3 + 570c9b3 Thu Feb 23 12:12:43 2017 -0600 David Alger Updated capistrano configuration + No changes to deploy on web2 (from and to are the same: 2.1 -> 2.1) +``` + +When there are no changes due for deployment to any host, a warning requiring confirmation will be emitted by default: -```ruby -require 'capistrano/magento2/notifier' +``` +No changes to deploy on web1 (from and to are the same: 2.1 -> 2.1) +No changes to deploy on web2 (from and to are the same: 2.1 -> 2.1) +Are you sure you want to continue? [y/n] ``` -**Notice:** The `terminal-notifier` gem is currently macOS specific and thus can not be used on generic *nix environments. Because this gem has been known to cause ruby stability issues on certain non-macOS environments, it is not specified as a hard requirement in this gem's gemspec. When using this functionality, it is expected the gem either be already present on your working environment or be added to your project's `Gemfile`: +This conformational warning can be disabled by including the following in your project's configuration: ```ruby -gem 'terminal-notifier' +set :magento_deploy_pending_warn, false ``` -### Pending Changes +### Pending Changes Configuration -This gem configuration include specifies [capistrano-pending](https://rubygems.org/gems/capistrano-pending) as a dependency and adds some (optional) custom functionality on top of that gem: Any time the `deploy` command is run, a one line summary of git commits that will be deployed will be displayed. If the server(s) you are deploying to already have the latest changes, you will be warned of this and a prompt will appear confirming that you want to continue deploying. +| setting | what it does +| -------------------------------- | ------- | --- +| `:magento_deploy_pending_role` | Roles to check for pending changes on. This defaults to `:all` +| `:magento_deploy_pending_warn` | Set this to `false` to disable the conformational warning on zero-change deployment +| `:magento_deploy_pending_format` | Can be used to set a custom change log format. See `defaults.rb` for example. -To add the `capistrano-pending` gem's enhanced functionality to you project, add the following line to your `Capfile`: +### Pending Changes Tasks + +| cap command | what it does | +| ------------------------------------- | -------------------------------------------------- | +| deploy:pending | Displays a summary of commits pending deployment | + +Note: For more details including screenshots of what this functionality does, reference [this post](https://github.com/davidalger/capistrano-magento2/issues/58#issuecomment-282404477). + +## Terminal Notifier on OS X + +This gem includes an optional configuration file include which adds notification support via the [terminal-notifier](https://rubygems.org/gems/terminal-notifier) gem. To configure notifications, simply add the following line to your `Capfile`: ```ruby -require 'capistrano/magento2/pending' +require 'capistrano/magento2/notifier' ``` -In order to make the `capistrano-pending` gem fully compatible with this gem out of the box, the `:capistrano_pending_role` setting has been configured to default to the value of `:magento_deploy_setup_role`. The `capistrano-pending` gem by default looks only at the `:db` role, breaking things if a project does not have code deployed to servers under the `:db` role, as would be the case when using a server configuration similar to the following: +**Notice:** The `terminal-notifier` gem is currently macOS specific and thus can not be used on generic *nix environments. Because this gem has been known to cause ruby stability issues on certain non-macOS environments, it is not specified as a hard requirement in this gem's gemspec. When using this functionality, it is expected the gem either be already present on your working environment or be added to your project's `Gemfile`: ```ruby -role :app, %w{ - www-data@web1 - www-data@web2 -} +gem 'terminal-notifier' ``` ## Development From e59e1ac93fa69425f4c9b5f78a1714d763e3b608 Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 24 Feb 2017 16:00:06 -0600 Subject: [PATCH 24/35] Updated CL and version number --- CHANGELOG.md | 5 +++-- lib/capistrano/magento2/version.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6317057..6a0dfec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ # Capistrano::Magento2 Change Log -UNRELEASED +0.6.0 ========== +* Added full-featured pending change logging functionality. See README for details (issue #58) * Fixed inability to set PATH in capistrano configuration vs `.bashrc` file (issue #62) -* Fixed potential incompatibility with `capistrano-pending` default deployment settings (issue #58) * Updated README to reflect removing the `terminal-notifier` gem as a hard dependency (issue #19) +* Removed `capistrano-pending` as a dependency (issue #58) 0.5.9 ========== diff --git a/lib/capistrano/magento2/version.rb b/lib/capistrano/magento2/version.rb index 666c92a..a29f972 100644 --- a/lib/capistrano/magento2/version.rb +++ b/lib/capistrano/magento2/version.rb @@ -9,6 +9,6 @@ module Capistrano module Magento2 - VERSION = '0.5.9' + VERSION = '0.6.0' end end From ad9c06e9e54ea7d9fc82f8b782b171e386dfdb11 Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 24 Feb 2017 16:06:52 -0600 Subject: [PATCH 25/35] Fixed spelling error in README (lame spell checker, lame) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7861b5b..21508c6 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ No changes to deploy on web2 (from and to are the same: 2.1 -> 2.1) Are you sure you want to continue? [y/n] ``` -This conformational warning can be disabled by including the following in your project's configuration: +This confirmational warning can be disabled by including the following in your project's configuration: ```ruby set :magento_deploy_pending_warn, false From caf2f3e12ccd72e96caab4a77812a2e889db8ffa Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 24 Feb 2017 16:08:28 -0600 Subject: [PATCH 26/35] README corrections --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 21508c6..c6f70a0 100644 --- a/README.md +++ b/README.md @@ -243,9 +243,9 @@ set :magento_deploy_pending_warn, false | setting | what it does | -------------------------------- | ------- | --- -| `:magento_deploy_pending_role` | Roles to check for pending changes on. This defaults to `:all` -| `:magento_deploy_pending_warn` | Set this to `false` to disable the conformational warning on zero-change deployment -| `:magento_deploy_pending_format` | Can be used to set a custom change log format. See `defaults.rb` for example. +| `:magento_deploy_pending_role` | Role to check for pending changes on; defaults to `:all` +| `:magento_deploy_pending_warn` | Set this to `false` to disable confirmational warning on zero-change deployments +| `:magento_deploy_pending_format` | Can be used to set a custom change log format; refer to `defaults.rb` for example ### Pending Changes Tasks From 264a7147dc6ab38bfbec8ab58a9802d8eef4ceb0 Mon Sep 17 00:00:00 2001 From: David Alger Date: Mon, 27 Feb 2017 11:29:43 -0600 Subject: [PATCH 27/35] Updated pending change log hook --- CHANGELOG.md | 4 ++++ lib/capistrano/tasks/pending.rake | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a0dfec..6bbe40e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Capistrano::Magento2 Change Log +UNRELEASED + +* Changed pending change log to hook into before `deploy:check` (previously hooked before `deploy`) + 0.6.0 ========== diff --git a/lib/capistrano/tasks/pending.rake b/lib/capistrano/tasks/pending.rake index 5cd8fd5..647f2cb 100644 --- a/lib/capistrano/tasks/pending.rake +++ b/lib/capistrano/tasks/pending.rake @@ -9,7 +9,7 @@ include Capistrano::Magento2::Pending -before :deploy, 'deploy:pending:warn' +before 'deploy:check', 'deploy:pending:warn' namespace :deploy do desc "Displays a summary of commits pending deployment" From 6825ef9b71416347680aa50f41078257ceb26d55 Mon Sep 17 00:00:00 2001 From: David Alger Date: Mon, 27 Feb 2017 13:13:36 -0600 Subject: [PATCH 28/35] Cleaned up add auth credential settings and added information to README Resolves #56 --- CHANGELOG.md | 1 + README.md | 13 +++++++++++++ lib/capistrano/magento2/defaults.rb | 7 ++++--- lib/capistrano/tasks/magento.rake | 21 +++++++++++++++------ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bbe40e..be8ed92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ UNRELEASED +* Added ability to configure Magento's composer authentication keys. See README for details (PR #56) * Changed pending change log to hook into before `deploy:check` (previously hooked before `deploy`) 0.6.0 diff --git a/README.md b/README.md index 7861b5b..89f2319 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,19 @@ If you would like to customize the linked files or directories for your project, append :linked_dirs, 'path/to/link' ``` +### Composer Auth Credentials + +Magento 2's composer repository requires auth credentials to install. These can be set on target servers in a global composer `auth.json` file, the project's `composer.json` or by setting them in your deployment configuration using the following two settings: + +```ruby +set :magento_auth_public_key, '' +set :magento_auth_private_key, '' +``` + +To obtain these credentials, reference the official documentation on DevDocs: [Get your authentication keys](http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html) + +**Caution:** When using these settings, the values will be logged to the `log/capistrano.log` file by SSHKit. They will not, however, be included in the general command output by default. + ### Magento 2 Deploy Routine A pre-built deploy routine is available out-of-the-box. This can be overriden on a per-project basis by including only the Magento 2 specific tasks and defining your own `deploy.rake` file under `lib/capistrano/tasks` in your projects Capistrano install location. diff --git a/lib/capistrano/magento2/defaults.rb b/lib/capistrano/magento2/defaults.rb index d881978..dd5ea78 100644 --- a/lib/capistrano/magento2/defaults.rb +++ b/lib/capistrano/magento2/defaults.rb @@ -31,9 +31,10 @@ 'var/tmp' ) -# deploy auth defaults -set :magento_auth_public_key, fetch(:magento_auth_public_key, '') -set :magento_auth_private_key, fetch(:magento_auth_private_key, '') +# magento composer repository auth credentials +set :magento_auth_repo_name, fetch(:magento_auth_repo_name, 'http-basic.repo.magento.com') +set :magento_auth_public_key, fetch(:magento_auth_public_key, false) +set :magento_auth_private_key, fetch(:magento_auth_private_key, false) # deploy permissions defaults set :magento_deploy_chmod_d, fetch(:magento_deploy_chmod_d, '2770') diff --git a/lib/capistrano/tasks/magento.rake b/lib/capistrano/tasks/magento.rake index 63a8f7d..4f8050b 100644 --- a/lib/capistrano/tasks/magento.rake +++ b/lib/capistrano/tasks/magento.rake @@ -81,7 +81,7 @@ namespace :magento do namespace :composer do desc 'Run composer install' - task :install do + task :install => :auth_config do on release_roles :all do within release_path do @@ -91,11 +91,6 @@ namespace :magento do composer_flags += ' --optimize-autoloader' end - if fetch(:magento_auth_public_key).to_s != '' and fetch(:magento_auth_private_key).to_s != '' - execute :composer, :config, "http-basic.repo.magento.com", - fetch(:magento_auth_public_key), fetch(:magento_auth_private_key), "2>&1" - end - execute :composer, "install #{composer_flags} 2>&1" if fetch(:magento_deploy_production) and magento_version >= Gem::Version.new('2.1') @@ -111,6 +106,20 @@ namespace :magento do end end end + + task :auth_config do + on release_roles :all do + within release_path do + if fetch(:magento_auth_public_key) and fetch(:magento_auth_private_key) + execute :composer, :config, '-q', + fetch(:magento_auth_repo_name), + fetch(:magento_auth_public_key), + fetch(:magento_auth_private_key), + verbosity: Logger::DEBUG + end + end + end + end end namespace :deploy do From 1be640621f394336f2c2dc50fe6989aa68363104 Mon Sep 17 00:00:00 2001 From: David Alger Date: Thu, 30 Mar 2017 15:25:04 -0500 Subject: [PATCH 29/35] Fixed Magento version check failing on some servers due to ansi output in non-interactive shells resolves #64 --- CHANGELOG.md | 1 + lib/capistrano/magento2.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be8ed92..25568f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ UNRELEASED +* Fixed Magento version check failing on some servers due to ansi output in non-interactive shells (issue #64) * Added ability to configure Magento's composer authentication keys. See README for details (PR #56) * Changed pending change log to hook into before `deploy:check` (previously hooked before `deploy`) diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 8a0743f..3944b42 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -13,7 +13,7 @@ module Capistrano module Magento2 module Helpers def magento_version - return Gem::Version::new((capture :php, "-f #{release_path}/bin/magento -- -V").split(' ').pop) + return Gem::Version::new((capture :php, "-f #{release_path}/bin/magento -- -V --no-ansi").split(' ').pop) end def disabled_modules From ca4bba265df026dc797b4f9d21b3232d6f5679be Mon Sep 17 00:00:00 2001 From: David Alger Date: Fri, 31 Mar 2017 10:36:24 -0500 Subject: [PATCH 30/35] Version bump --- CHANGELOG.md | 3 ++- lib/capistrano/magento2/version.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25568f3..4526d34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Capistrano::Magento2 Change Log -UNRELEASED +0.6.1 +========== * Fixed Magento version check failing on some servers due to ansi output in non-interactive shells (issue #64) * Added ability to configure Magento's composer authentication keys. See README for details (PR #56) diff --git a/lib/capistrano/magento2/version.rb b/lib/capistrano/magento2/version.rb index a29f972..3f6316a 100644 --- a/lib/capistrano/magento2/version.rb +++ b/lib/capistrano/magento2/version.rb @@ -9,6 +9,6 @@ module Capistrano module Magento2 - VERSION = '0.6.0' + VERSION = '0.6.1' end end From 1c4c57f0a8ceffe1c8afac6b63bf1dff3c84d91d Mon Sep 17 00:00:00 2001 From: David Alger Date: Mon, 10 Apr 2017 11:35:39 -0500 Subject: [PATCH 31/35] Fixed issue where ./update dir may exist without a composer.json file, causing deployment failure --- CHANGELOG.md | 5 +++++ lib/capistrano/tasks/magento.rake | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4526d34..2ac65fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Capistrano::Magento2 Change Log +UNRELEASED +========== + +* Fixed issue where ./update dir may exist without a composer.json file, causing deployment failure + 0.6.1 ========== diff --git a/lib/capistrano/tasks/magento.rake b/lib/capistrano/tasks/magento.rake index 4f8050b..f642231 100644 --- a/lib/capistrano/tasks/magento.rake +++ b/lib/capistrano/tasks/magento.rake @@ -98,10 +98,10 @@ namespace :magento do execute :composer, "install #{composer_flags} 2>&1" # removes require-dev components from prev command end - if test "[ -d #{release_path}/update ]" # can't count on this, but emit warning if not present + if test "[ -f #{release_path}/update/composer.json ]" # can't count on this, but emit warning if not present execute :composer, "install #{composer_flags} -d ./update 2>&1" else - puts "\e[0;31m Warning: ./update dir does not exist in repository!\n\e[0m\n" + puts "\e[0;31m Warning: ./update/composer.json does not exist in repository!\n\e[0m\n" end end end From fe516861550609432252ea73aad690cadfbe03a3 Mon Sep 17 00:00:00 2001 From: David Alger Date: Mon, 10 Apr 2017 11:40:24 -0500 Subject: [PATCH 32/35] Updated uses of bin/magento where output is parsed to include `--no-ansi` to eliminate potential failures --- CHANGELOG.md | 1 + lib/capistrano/magento2.rb | 4 ++-- lib/capistrano/tasks/magento.rake | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ac65fc..80fa978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ UNRELEASED ========== * Fixed issue where ./update dir may exist without a composer.json file, causing deployment failure +* Updated uses of bin/magento where output is parsed to include `--no-ansi` to eliminate potential failures 0.6.1 ========== diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 3944b42..0900406 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -17,7 +17,7 @@ def magento_version end def disabled_modules - output = capture :magento, 'module:status' + output = capture :magento, 'module:status --no-ansi' output = output.split("disabled modules:\n", 2)[1] if output == nil or output.strip == "None" @@ -48,7 +48,7 @@ module Setup def static_content_deploy params Helpers.set_pipefail output = capture :magento, - "setup:static-content:deploy #{params} | stdbuf -o0 tr -d .", + "setup:static-content:deploy --no-ansi #{params} | stdbuf -o0 tr -d .", verbosity: Logger::INFO Helpers.unset_pipefail diff --git a/lib/capistrano/tasks/magento.rake b/lib/capistrano/tasks/magento.rake index f642231..4804a71 100644 --- a/lib/capistrano/tasks/magento.rake +++ b/lib/capistrano/tasks/magento.rake @@ -183,7 +183,7 @@ namespace :magento do task :upgrade do on primary fetch(:magento_deploy_setup_role) do within release_path do - db_status = capture :magento, 'setup:db:status', verbosity: Logger::INFO + db_status = capture :magento, 'setup:db:status --no-ansi', verbosity: Logger::INFO if not db_status.to_s.include? 'All modules are up to date' execute :magento, 'setup:db-schema:upgrade' @@ -236,9 +236,9 @@ namespace :magento do # we have to use multi-tenant currently. However, the multi-tenant is being dropped in 2.1 and is no longer # present in the develop mainline, so we are testing for multi-tenant presence for long-term portability. if test :magento, 'setup:di:compile-multi-tenant --help >/dev/null 2>&1' - output = capture :magento, 'setup:di:compile-multi-tenant', verbosity: Logger::INFO + output = capture :magento, 'setup:di:compile-multi-tenant --no-ansi', verbosity: Logger::INFO else - output = capture :magento, 'setup:di:compile', verbosity: Logger::INFO + output = capture :magento, 'setup:di:compile --no-ansi', verbosity: Logger::INFO end # 2.0.x never returns a non-zero exit code for errors, so manually check string From 0de52d1836b4a4c49b36fd276e11ab64d7985068 Mon Sep 17 00:00:00 2001 From: David Alger Date: Mon, 10 Apr 2017 11:40:34 -0500 Subject: [PATCH 33/35] Improved error reporting on static content deployment failure --- CHANGELOG.md | 1 + lib/capistrano/magento2.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80fa978..2a54c00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ UNRELEASED * Fixed issue where ./update dir may exist without a composer.json file, causing deployment failure * Updated uses of bin/magento where output is parsed to include `--no-ansi` to eliminate potential failures +* Improved error reporting on static content deployment failure 0.6.1 ========== diff --git a/lib/capistrano/magento2.rb b/lib/capistrano/magento2.rb index 0900406..cc85b84 100644 --- a/lib/capistrano/magento2.rb +++ b/lib/capistrano/magento2.rb @@ -55,12 +55,12 @@ def static_content_deploy params # String based error checking is here to catch errors in Magento 2.1.0 and earlier; later versions will exit # immediately when a console exit code is retruned, never evaluating this code. if not output.to_s.include? 'New version of deployed files' - raise Exception, "\e[0;31mFailed to compile static assets\e[0m" + raise Exception, "\e[0;31mFailed to compile static assets. No new version found in command output!\e[0m" end output.to_s.each_line { |line| if line.split('errors: ', 2).pop.to_i > 0 - raise Exception, "\e[0;31mFailed to compile static assets\e[0m" + raise Exception, "\e[0;31mFailed to compile static assets. Errors found in command output: #{line}\e[0m" end } end From caa957f32bcf0958b4ce7a2788b5f7753a464921 Mon Sep 17 00:00:00 2001 From: David Alger Date: Mon, 10 Apr 2017 12:14:53 -0500 Subject: [PATCH 34/35] Added setting `:magento_deploy_jobs` to support configuring number of parallel static content deployment tasks Resolves #61 --- CHANGELOG.md | 1 + README.md | 1 + lib/capistrano/magento2/defaults.rb | 1 + lib/capistrano/tasks/magento.rake | 14 ++++++++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a54c00..ecd5286 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ UNRELEASED ========== +* Added setting `:magento_deploy_jobs` to support configuring number of parallel static content deployment tasks * Fixed issue where ./update dir may exist without a composer.json file, causing deployment failure * Updated uses of bin/magento where output is parsed to include `--no-ansi` to eliminate potential failures * Improved error reporting on static content deployment failure diff --git a/README.md b/README.md index 2af75a4..740176a 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ Before you can use Capistrano to deploy, you must configure the `config/deploy.r | `:magento_deploy_cache_shared` | `true` | If true, cache operations are restricted to the primary node in setup role | `:magento_deploy_languages` | `['en_US']` | Array of languages passed to static content deploy routine | `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy (Magento 2.1.1 and later) +| `:magento_deploy_jobs` | `4` | Number of threads to use for static content deploy (Magento 2.1.1 and later) | `:magento_deploy_composer` | `true` | Enables composer install behaviour in the built-in deploy routine | `:magento_deploy_production` | `true` | Enables production specific DI compilation and static content generation | `:magento_deploy_maintenance` | `true` | Enables use of maintenance mode while magento:setup:upgrade runs diff --git a/lib/capistrano/magento2/defaults.rb b/lib/capistrano/magento2/defaults.rb index dd5ea78..4925bb8 100644 --- a/lib/capistrano/magento2/defaults.rb +++ b/lib/capistrano/magento2/defaults.rb @@ -48,6 +48,7 @@ set :magento_deploy_maintenance, fetch(:magento_deploy_maintenance, true) set :magento_deploy_production, fetch(:magento_deploy_production, true) set :magento_deploy_themes, fetch(:magento_deploy_themes, []) +set :magento_deploy_jobs, fetch(:magento_deploy_jobs, nil) # this defaults to 4 when supported by bin/magento # deploy targetting defaults set :magento_deploy_setup_role, fetch(:magento_deploy_setup_role, :all) diff --git a/lib/capistrano/tasks/magento.rake b/lib/capistrano/tasks/magento.rake index 4804a71..905b3d2 100644 --- a/lib/capistrano/tasks/magento.rake +++ b/lib/capistrano/tasks/magento.rake @@ -259,6 +259,7 @@ namespace :magento do deploy_languages = fetch(:magento_deploy_languages).join(' ') deploy_themes = fetch(:magento_deploy_themes) + deploy_jobs = fetch(:magento_deploy_jobs) if deploy_themes.count() > 0 and _magento_version >= Gem::Version.new('2.1.1') deploy_themes = deploy_themes.join(' -t ').prepend(' -t ') @@ -269,6 +270,15 @@ namespace :magento do deploy_themes = nil end + if deploy_jobs and _magento_version >= Gem::Version.new('2.1.1') + deploy_jobs = "--jobs #{deploy_jobs} " + elsif deploy_jobs + warn "\e[0;31mWarning: the :magento_deploy_jobs setting is only supported in Magento 2.1.1 and later\e[0m" + deploy_jobs = nil + else + deploy_jobs = nil + end + # Output is being checked for a success message because this command may easily fail due to customizations # and 2.0.x CLI commands do not return error exit codes on failure. See magento/magento2#3060 for details. within release_path do @@ -277,7 +287,7 @@ namespace :magento do execute "touch #{release_path}/pub/static/deployed_version.txt" # Generates all but the secure versions of RequireJS configs - static_content_deploy "#{deploy_languages}#{deploy_themes}" + static_content_deploy "#{deploy_jobs}#{deploy_languages}#{deploy_themes}" end # Run again with HTTPS env var set to 'on' to pre-generate secure versions of RequireJS configs @@ -288,7 +298,7 @@ namespace :magento do deploy_flags = nil if _magento_version <= Gem::Version.new('2.1.0') within release_path do with(https: 'on') { - static_content_deploy "#{deploy_languages}#{deploy_themes}#{deploy_flags}" + static_content_deploy "#{deploy_jobs}#{deploy_languages}#{deploy_themes}#{deploy_flags}" } end end end From ab26b94563a9a0c62c87a30345b4c8d8dda8772a Mon Sep 17 00:00:00 2001 From: David Alger Date: Mon, 10 Apr 2017 12:35:16 -0500 Subject: [PATCH 35/35] Prep for release --- CHANGELOG.md | 2 +- lib/capistrano/magento2/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecd5286..76719af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Capistrano::Magento2 Change Log -UNRELEASED +0.6.2 ========== * Added setting `:magento_deploy_jobs` to support configuring number of parallel static content deployment tasks diff --git a/lib/capistrano/magento2/version.rb b/lib/capistrano/magento2/version.rb index 3f6316a..2cbf8e3 100644 --- a/lib/capistrano/magento2/version.rb +++ b/lib/capistrano/magento2/version.rb @@ -9,6 +9,6 @@ module Capistrano module Magento2 - VERSION = '0.6.1' + VERSION = '0.6.2' end end