From 7b20fa62bb8ebc5864f68836e9ebe3ce915bd7b0 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Sat, 7 Mar 2026 12:09:08 -0800 Subject: [PATCH 01/17] Fix config import needed on revert. #4180 --- recipe/magento2.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index be1bf3b6f..918ed487c 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -370,7 +370,14 @@ function magentoDeployAssetsSplit(string $area) after('deploy:symlink', 'magento:cache:flush'); -after('deploy:failed', 'magento:maintenance:disable'); +after('deploy:failed','deploy:magento:failed'); + +//Run Magento Deployment Failure Tasks +desc('Run magento post deployment failure tasks.'); +task('deploy:magento:failed',[ + 'magento:config:import', + 'magento:maintenance:disable' +]); // Artifact deployment section From 0c06c6278e258e6f60afe0994161e70e0bcec7d2 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Sat, 7 Mar 2026 21:53:47 +0000 Subject: [PATCH 02/17] Run docgen --- docs/recipe/magento2.md | 54 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 9c7d6b7f8..b9ee97433 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -380,7 +380,7 @@ true ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L378) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L385) Artifact deployment section The file the artifact is saved to @@ -391,7 +391,7 @@ The file the artifact is saved to ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L381) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L388) The directory the artifact is saved in @@ -401,7 +401,7 @@ The directory the artifact is saved in ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L385) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L392) Points to a file with a list of files to exclude from packaging. The format is as with the `tar --exclude-from=[file]` option @@ -412,7 +412,7 @@ The format is as with the `tar --exclude-from=[file]` option ### build_from_repo -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L388) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L395) If set to true, the artifact is built from a clean copy of the project repository instead of the current working directory @@ -422,7 +422,7 @@ false ### repository -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L391) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L398) Overrides [repository](/docs/recipe/common.md#repository) from `recipe/common.php`. @@ -434,7 +434,7 @@ null ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L394) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L401) The relative path to the artifact file. If the directory does not exist, it will be created @@ -447,7 +447,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L402) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L409) The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings :::info Autogenerated @@ -458,14 +458,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L474) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L481) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L476) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L483) Array of shared directories that will be added to the default shared_dirs without overriding @@ -639,8 +639,16 @@ This task is group task which contains next tasks: * [deploy:publish](/docs/recipe/common.md#deploy-publish) +### deploy\:magento\:failed {#deploy-magento-failed} +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L377) + +Run magento post deployment failure tasks. + +Run Magento Deployment Failure Tasks + + ### artifact\:package {#artifact-package} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L413) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L420) Packages all relevant files in an artifact. @@ -648,7 +656,7 @@ tasks section ### artifact\:upload {#artifact-upload} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L423) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L430) Uploads artifact in release folder for extraction. @@ -656,7 +664,7 @@ Uploads artifact in release folder for extraction. ### artifact\:extract {#artifact-extract} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L428) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L435) Extracts artifact in release path. @@ -664,7 +672,7 @@ Extracts artifact in release path. ### build\:remove-generated {#build-remove-generated} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L434) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L441) Clears generated files prior to building. @@ -672,7 +680,7 @@ Clears generated files prior to building. ### build\:prepare {#build-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L439) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L446) Prepare local artifact build. @@ -680,7 +688,7 @@ Prepare local artifact build. ### artifact\:build {#artifact-build} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L464) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L471) Builds an artifact. @@ -697,7 +705,7 @@ This task is group task which contains next tasks: ### deploy\:additional-shared {#deploy-additional-shared} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L480) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L487) Adds additional files and dirs to the list of shared files and dirs. @@ -705,7 +713,7 @@ Adds additional files and dirs to the list of shared files and dirs. ### magento\:set_cache_prefix {#magento-set_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L495) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L502) Update cache id_prefix. @@ -719,7 +727,7 @@ after('deploy:magento', 'magento:cleanup_cache_prefix'); ### magento\:cleanup_cache_prefix {#magento-cleanup_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L535) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L542) Cleanup cache id_prefix env files. @@ -727,7 +735,7 @@ After successful deployment, move the tmp_env.php file to env.php ready for next ### magento\:cron\:stop {#magento-cron-stop} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L551) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L558) Remove cron from crontab and kill running cron jobs. @@ -739,7 +747,7 @@ To use this feature, add the following to your deployer scripts: ### magento\:cron\:install {#magento-cron-install} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L567) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L574) Install cron in crontab. @@ -751,7 +759,7 @@ To use this feature, add the following to your deployer scripts: ### artifact\:prepare {#artifact-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L573) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L580) Prepares an artifact on the target server. @@ -771,7 +779,7 @@ This task is group task which contains next tasks: ### artifact\:finish {#artifact-finish} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L586) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L593) Executes the tasks after artifact is released. @@ -787,7 +795,7 @@ This task is group task which contains next tasks: ### artifact\:deploy {#artifact-deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L595) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L602) Actually releases the artifact deployment. From d1f0fde0a6b7be2f191a6575c012dea5082fa13c Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Sat, 7 Mar 2026 22:05:58 +0000 Subject: [PATCH 03/17] Fix code quality and style --- recipe/magento2.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 918ed487c..74bd53000 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -370,13 +370,13 @@ function magentoDeployAssetsSplit(string $area) after('deploy:symlink', 'magento:cache:flush'); -after('deploy:failed','deploy:magento:failed'); +after('deploy:failed', 'deploy:magento:failed'); //Run Magento Deployment Failure Tasks desc('Run magento post deployment failure tasks.'); -task('deploy:magento:failed',[ +task('deploy:magento:failed', [ 'magento:config:import', - 'magento:maintenance:disable' + 'magento:maintenance:disable', ]); // Artifact deployment section From d9252b4d151136212753bc23ae3eb6f4968044c7 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Sat, 7 Mar 2026 22:13:53 +0000 Subject: [PATCH 04/17] Update docs --- docs/recipe/magento2.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index b9ee97433..341d09c07 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -647,6 +647,11 @@ Run magento post deployment failure tasks. Run Magento Deployment Failure Tasks +This task is group task which contains next tasks: +* [magento:config:import](/docs/recipe/magento2.md#magento-config-import) +* [magento:maintenance:disable](/docs/recipe/magento2.md#magento-maintenance-disable) + + ### artifact\:package {#artifact-package} [Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L420) From bdb600be9e62631023a5ecb891c1d894d026178a Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 09:46:30 -0700 Subject: [PATCH 05/17] Update recipe/magento2.php Remove unneeded comment for docs. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- recipe/magento2.php | 1 - 1 file changed, 1 deletion(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 74bd53000..22b319c33 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -372,7 +372,6 @@ function magentoDeployAssetsSplit(string $area) after('deploy:failed', 'deploy:magento:failed'); -//Run Magento Deployment Failure Tasks desc('Run magento post deployment failure tasks.'); task('deploy:magento:failed', [ 'magento:config:import', From 1e998508a4efc862a37324b27cdc75b672635fcc Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 17:48:58 +0000 Subject: [PATCH 06/17] Ensure bin/magento commands run on last secussfull release on failed deployment. --- recipe/magento2.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 22b319c33..54cea111e 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -106,6 +106,9 @@ '{{magento_dir}}/var/view_preprocessed/*', ]); +// WARNING: Do not use {{bin/magento}} in deploy:failed handlers - release_or_current_path points to the failed +// release during failure, not the live one. Use {{current_path}} explicitly instead. +// See: config_import_needed_on_current, magento:config:import:on-current, magento:maintenance:enable/disable. set('bin/magento', '{{release_or_current_path}}/{{magento_dir}}/bin/magento'); set('magento_version', function () { @@ -129,6 +132,21 @@ return false; }); +set('config_import_needed_on_current', function () { + // detect if app:config:import is needed on the current (live) release + // do not use {{bin/magento}} as it resolves via release_or_current_path which is unreliable in failure scenarios + try { + run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:status'); + } catch (RunException $e) { + if ($e->getExitCode() == CONFIG_IMPORT_NEEDED_EXIT_CODE) { + return true; + } + + throw $e; + } + return false; +}); + set('database_upgrade_needed', function () { // detect if db upgrade is needed try { @@ -318,6 +336,16 @@ function magentoDeployAssetsSplit(string $area) } }); +desc('Config Import on current release'); +task('magento:config:import:on-current', function () { + if (get('config_import_needed_on_current')) { + // do not use {{bin/magento}} as it must run on the current (last successful) release in failure scenarios + run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:import --no-interaction'); + } else { + writeln('App config is up to date => import skipped'); + } +}); + desc('Upgrades magento database'); task('magento:upgrade:db', function () { if (get('database_upgrade_needed')) { @@ -374,7 +402,7 @@ function magentoDeployAssetsSplit(string $area) desc('Run magento post deployment failure tasks.'); task('deploy:magento:failed', [ - 'magento:config:import', + 'magento:config:import:on-current', 'magento:maintenance:disable', ]); From bf6efb1e9e3a7c419c679947c64a4575f5e05933 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 10:49:33 -0700 Subject: [PATCH 07/17] Update recipe/magento2.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- recipe/magento2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 54cea111e..59fe28b01 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -400,7 +400,7 @@ function magentoDeployAssetsSplit(string $area) after('deploy:failed', 'deploy:magento:failed'); -desc('Run magento post deployment failure tasks.'); +desc('Run Magento post-deployment failure tasks'); task('deploy:magento:failed', [ 'magento:config:import:on-current', 'magento:maintenance:disable', From 9354d976f05f08687504d52157b2fe080df5d297 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 19:47:10 +0000 Subject: [PATCH 08/17] Generate docs --- docs/recipe/magento2.md | 121 +++++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 50 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 341d09c07..7e2945fea 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -302,9 +302,11 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### bin/magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L109) - +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L112) +WARNING: Do not use [bin/magento](/docs/recipe/magento2.md#bin/magento) in deploy:failed handlers - release_or_current_path points to the failed +release during failure, not the live one. Use [current_path](/docs/recipe/common.md#current_path) explicitly instead. +See: config_import_needed_on_current, magento:config:import:on-current, magento:maintenance:enable/disable. ```php title="Default value" '{{release_or_current_path}}/{{magento_dir}}/bin/magento' @@ -312,7 +314,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### magento_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L111) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L114) @@ -325,7 +327,18 @@ return $matches[0] ?? '2.0'; ### config_import_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L118) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L121) + + +:::info Autogenerated +The value of this configuration is autogenerated on access. +::: + + + + +### config_import_needed_on_current +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L135) :::info Autogenerated @@ -336,7 +349,7 @@ The value of this configuration is autogenerated on access. ### database_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L132) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L150) :::info Autogenerated @@ -347,7 +360,7 @@ The value of this configuration is autogenerated on access. ### full_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L147) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L165) @@ -359,7 +372,7 @@ return false; ### upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L153) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L171) :::info Autogenerated @@ -370,7 +383,7 @@ The value of this configuration is autogenerated on access. ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L163) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L181) Deploy without setting maintenance mode if possible @@ -380,7 +393,7 @@ true ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L385) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L412) Artifact deployment section The file the artifact is saved to @@ -391,7 +404,7 @@ The file the artifact is saved to ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L388) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L415) The directory the artifact is saved in @@ -401,7 +414,7 @@ The directory the artifact is saved in ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L392) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L419) Points to a file with a list of files to exclude from packaging. The format is as with the `tar --exclude-from=[file]` option @@ -412,7 +425,7 @@ The format is as with the `tar --exclude-from=[file]` option ### build_from_repo -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L395) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L422) If set to true, the artifact is built from a clean copy of the project repository instead of the current working directory @@ -422,7 +435,7 @@ false ### repository -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L398) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L425) Overrides [repository](/docs/recipe/common.md#repository) from `recipe/common.php`. @@ -434,7 +447,7 @@ null ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L401) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L428) The relative path to the artifact file. If the directory does not exist, it will be created @@ -447,7 +460,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L409) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L436) The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings :::info Autogenerated @@ -458,14 +471,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L481) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L508) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L483) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L510) Array of shared directories that will be added to the default shared_dirs without overriding @@ -475,7 +488,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento\:compile {#magento-compile} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L173) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L191) Compiles magento di. @@ -488,7 +501,7 @@ e.g. ### magento\:deploy\:assets {#magento-deploy-assets} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L199) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L217) Deploys assets. @@ -515,7 +528,7 @@ in `app/etc/config.php`, e.g.: ### magento\:deploy\:assets\:adminhtml {#magento-deploy-assets-adminhtml} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L216) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L234) Deploys assets for backend only. @@ -523,7 +536,7 @@ Deploys assets for backend only. ### magento\:deploy\:assets\:frontend {#magento-deploy-assets-frontend} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L221) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L239) Deploys assets for frontend only. @@ -531,7 +544,7 @@ Deploys assets for frontend only. ### magento\:sync\:content_version {#magento-sync-content_version} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L284) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L302) Syncs content version. @@ -539,7 +552,7 @@ Syncs content version. ### magento\:maintenance\:enable {#magento-maintenance-enable} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L294) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L312) Enables maintenance mode. @@ -547,7 +560,7 @@ Enables maintenance mode. ### magento\:maintenance\:disable {#magento-maintenance-disable} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L300) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L318) Disables maintenance mode. @@ -555,7 +568,7 @@ Disables maintenance mode. ### magento\:maintenance\:enable-if-needed {#magento-maintenance-enable-if-needed} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L306) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L324) Set maintenance mode if needed. @@ -563,15 +576,23 @@ Set maintenance mode if needed. ### magento\:config\:import {#magento-config-import} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L313) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L331) Config Import. +### magento\:config\:import\:on-current {#magento-config-import-on-current} +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L340) + +Config Import on current release. + + + + ### magento\:upgrade\:db {#magento-upgrade-db} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L322) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L350) Upgrades magento database. @@ -579,7 +600,7 @@ Upgrades magento database. ### magento\:upgrade {#magento-upgrade} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L334) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L362) Run upgrades if needed. @@ -587,7 +608,7 @@ Run upgrades if needed. ### magento\:cache\:flush {#magento-cache-flush} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L343) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L371) Flushes Magento Cache. @@ -595,7 +616,7 @@ Flushes Magento Cache. ### deploy\:magento {#deploy-magento} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L348) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L376) Magento2 deployment operations. @@ -611,7 +632,7 @@ This task is group task which contains next tasks: ### magento\:build {#magento-build} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L357) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L385) Magento2 build operations. @@ -624,7 +645,7 @@ This task is group task which contains next tasks: ### deploy {#deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L363) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L391) Deploys your project. @@ -640,20 +661,20 @@ This task is group task which contains next tasks: ### deploy\:magento\:failed {#deploy-magento-failed} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L377) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L404) + +Run Magento post-deployment failure tasks. -Run magento post deployment failure tasks. -Run Magento Deployment Failure Tasks This task is group task which contains next tasks: -* [magento:config:import](/docs/recipe/magento2.md#magento-config-import) +* [magento:config:import:on-current](/docs/recipe/magento2.md#magento-config-import-on-current) * [magento:maintenance:disable](/docs/recipe/magento2.md#magento-maintenance-disable) ### artifact\:package {#artifact-package} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L420) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L447) Packages all relevant files in an artifact. @@ -661,7 +682,7 @@ tasks section ### artifact\:upload {#artifact-upload} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L430) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L457) Uploads artifact in release folder for extraction. @@ -669,7 +690,7 @@ Uploads artifact in release folder for extraction. ### artifact\:extract {#artifact-extract} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L435) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L462) Extracts artifact in release path. @@ -677,7 +698,7 @@ Extracts artifact in release path. ### build\:remove-generated {#build-remove-generated} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L441) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L468) Clears generated files prior to building. @@ -685,7 +706,7 @@ Clears generated files prior to building. ### build\:prepare {#build-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L446) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L473) Prepare local artifact build. @@ -693,7 +714,7 @@ Prepare local artifact build. ### artifact\:build {#artifact-build} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L471) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L498) Builds an artifact. @@ -710,7 +731,7 @@ This task is group task which contains next tasks: ### deploy\:additional-shared {#deploy-additional-shared} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L487) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L514) Adds additional files and dirs to the list of shared files and dirs. @@ -718,7 +739,7 @@ Adds additional files and dirs to the list of shared files and dirs. ### magento\:set_cache_prefix {#magento-set_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L502) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L529) Update cache id_prefix. @@ -732,7 +753,7 @@ after('deploy:magento', 'magento:cleanup_cache_prefix'); ### magento\:cleanup_cache_prefix {#magento-cleanup_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L542) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L569) Cleanup cache id_prefix env files. @@ -740,7 +761,7 @@ After successful deployment, move the tmp_env.php file to env.php ready for next ### magento\:cron\:stop {#magento-cron-stop} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L558) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L585) Remove cron from crontab and kill running cron jobs. @@ -752,7 +773,7 @@ To use this feature, add the following to your deployer scripts: ### magento\:cron\:install {#magento-cron-install} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L574) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L601) Install cron in crontab. @@ -764,7 +785,7 @@ To use this feature, add the following to your deployer scripts: ### artifact\:prepare {#artifact-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L580) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L607) Prepares an artifact on the target server. @@ -784,7 +805,7 @@ This task is group task which contains next tasks: ### artifact\:finish {#artifact-finish} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L593) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L620) Executes the tasks after artifact is released. @@ -800,7 +821,7 @@ This task is group task which contains next tasks: ### artifact\:deploy {#artifact-deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L602) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L629) Actually releases the artifact deployment. From 2df76ce3a0bd78fd0c48925d7a9f397cd1c56f95 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 20:07:49 +0000 Subject: [PATCH 09/17] Magento failure subtasks should fail gracefully in case of new or blank installs. --- recipe/magento2.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 59fe28b01..41fec3cc1 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -133,16 +133,24 @@ }); set('config_import_needed_on_current', function () { - // detect if app:config:import is needed on the current (live) release - // do not use {{bin/magento}} as it resolves via release_or_current_path which is unreliable in failure scenarios + + if (!test('[ -d {{current_path}}/{{magento_dir}} ] && [ -f {{current_path}}/{{magento_dir}}/bin/magento ]')) { + writeln('Current Magento installation is unavailable => import skipped'); + return false; + } + try { + // detect if app:config:import is needed on the current (live) release + // do not use {{bin/magento}} as it resolves via release_or_current_path which is unreliable in failure scenarios run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:status'); } catch (RunException $e) { if ($e->getExitCode() == CONFIG_IMPORT_NEEDED_EXIT_CODE) { return true; } - throw $e; + // In failure scenarios, non-status errors should not break deploy:failed handlers. + writeln('Unable to determine app config status on current release => import skipped'); + return false; } return false; }); @@ -338,11 +346,15 @@ function magentoDeployAssetsSplit(string $area) desc('Config Import on current release'); task('magento:config:import:on-current', function () { - if (get('config_import_needed_on_current')) { - // do not use {{bin/magento}} as it must run on the current (last successful) release in failure scenarios - run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:import --no-interaction'); - } else { - writeln('App config is up to date => import skipped'); + try { + if (get('config_import_needed_on_current')) { + // do not use {{bin/magento}} as it must run on the current (last successful) release in failure scenarios + run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:import --no-interaction'); + } else { + writeln('App config is up to date => import skipped'); + } + } catch (RunException $e) { + writeln('Unable to import app config on current release => import skipped'); } }); From 8825a0607fe48ec165e66b2a5aa29c246438c82a Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 20:16:13 +0000 Subject: [PATCH 10/17] update docs --- docs/recipe/magento2.md | 88 ++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 7e2945fea..503ba3f06 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -349,7 +349,7 @@ The value of this configuration is autogenerated on access. ### database_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L150) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L158) :::info Autogenerated @@ -360,7 +360,7 @@ The value of this configuration is autogenerated on access. ### full_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L165) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L173) @@ -372,7 +372,7 @@ return false; ### upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L171) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L179) :::info Autogenerated @@ -383,7 +383,7 @@ The value of this configuration is autogenerated on access. ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L181) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L189) Deploy without setting maintenance mode if possible @@ -393,7 +393,7 @@ true ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L412) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L424) Artifact deployment section The file the artifact is saved to @@ -404,7 +404,7 @@ The file the artifact is saved to ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L415) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L427) The directory the artifact is saved in @@ -414,7 +414,7 @@ The directory the artifact is saved in ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L419) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L431) Points to a file with a list of files to exclude from packaging. The format is as with the `tar --exclude-from=[file]` option @@ -425,7 +425,7 @@ The format is as with the `tar --exclude-from=[file]` option ### build_from_repo -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L422) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L434) If set to true, the artifact is built from a clean copy of the project repository instead of the current working directory @@ -435,7 +435,7 @@ false ### repository -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L425) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L437) Overrides [repository](/docs/recipe/common.md#repository) from `recipe/common.php`. @@ -447,7 +447,7 @@ null ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L428) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L440) The relative path to the artifact file. If the directory does not exist, it will be created @@ -460,7 +460,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L436) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L448) The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings :::info Autogenerated @@ -471,14 +471,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L508) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L520) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L510) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L522) Array of shared directories that will be added to the default shared_dirs without overriding @@ -488,7 +488,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento\:compile {#magento-compile} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L191) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L199) Compiles magento di. @@ -501,7 +501,7 @@ e.g. ### magento\:deploy\:assets {#magento-deploy-assets} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L217) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L225) Deploys assets. @@ -528,7 +528,7 @@ in `app/etc/config.php`, e.g.: ### magento\:deploy\:assets\:adminhtml {#magento-deploy-assets-adminhtml} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L234) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L242) Deploys assets for backend only. @@ -536,7 +536,7 @@ Deploys assets for backend only. ### magento\:deploy\:assets\:frontend {#magento-deploy-assets-frontend} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L239) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L247) Deploys assets for frontend only. @@ -544,7 +544,7 @@ Deploys assets for frontend only. ### magento\:sync\:content_version {#magento-sync-content_version} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L302) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L310) Syncs content version. @@ -552,7 +552,7 @@ Syncs content version. ### magento\:maintenance\:enable {#magento-maintenance-enable} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L312) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L320) Enables maintenance mode. @@ -560,7 +560,7 @@ Enables maintenance mode. ### magento\:maintenance\:disable {#magento-maintenance-disable} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L318) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L326) Disables maintenance mode. @@ -568,7 +568,7 @@ Disables maintenance mode. ### magento\:maintenance\:enable-if-needed {#magento-maintenance-enable-if-needed} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L324) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L332) Set maintenance mode if needed. @@ -576,7 +576,7 @@ Set maintenance mode if needed. ### magento\:config\:import {#magento-config-import} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L331) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L339) Config Import. @@ -584,7 +584,7 @@ Config Import. ### magento\:config\:import\:on-current {#magento-config-import-on-current} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L340) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L348) Config Import on current release. @@ -592,7 +592,7 @@ Config Import on current release. ### magento\:upgrade\:db {#magento-upgrade-db} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L350) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L362) Upgrades magento database. @@ -600,7 +600,7 @@ Upgrades magento database. ### magento\:upgrade {#magento-upgrade} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L362) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L374) Run upgrades if needed. @@ -608,7 +608,7 @@ Run upgrades if needed. ### magento\:cache\:flush {#magento-cache-flush} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L371) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L383) Flushes Magento Cache. @@ -616,7 +616,7 @@ Flushes Magento Cache. ### deploy\:magento {#deploy-magento} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L376) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L388) Magento2 deployment operations. @@ -632,7 +632,7 @@ This task is group task which contains next tasks: ### magento\:build {#magento-build} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L385) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L397) Magento2 build operations. @@ -645,7 +645,7 @@ This task is group task which contains next tasks: ### deploy {#deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L391) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L403) Deploys your project. @@ -661,7 +661,7 @@ This task is group task which contains next tasks: ### deploy\:magento\:failed {#deploy-magento-failed} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L404) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L416) Run Magento post-deployment failure tasks. @@ -674,7 +674,7 @@ This task is group task which contains next tasks: ### artifact\:package {#artifact-package} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L447) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L459) Packages all relevant files in an artifact. @@ -682,7 +682,7 @@ tasks section ### artifact\:upload {#artifact-upload} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L457) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L469) Uploads artifact in release folder for extraction. @@ -690,7 +690,7 @@ Uploads artifact in release folder for extraction. ### artifact\:extract {#artifact-extract} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L462) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L474) Extracts artifact in release path. @@ -698,7 +698,7 @@ Extracts artifact in release path. ### build\:remove-generated {#build-remove-generated} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L468) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L480) Clears generated files prior to building. @@ -706,7 +706,7 @@ Clears generated files prior to building. ### build\:prepare {#build-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L473) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L485) Prepare local artifact build. @@ -714,7 +714,7 @@ Prepare local artifact build. ### artifact\:build {#artifact-build} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L498) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L510) Builds an artifact. @@ -731,7 +731,7 @@ This task is group task which contains next tasks: ### deploy\:additional-shared {#deploy-additional-shared} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L514) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L526) Adds additional files and dirs to the list of shared files and dirs. @@ -739,7 +739,7 @@ Adds additional files and dirs to the list of shared files and dirs. ### magento\:set_cache_prefix {#magento-set_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L529) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L541) Update cache id_prefix. @@ -753,7 +753,7 @@ after('deploy:magento', 'magento:cleanup_cache_prefix'); ### magento\:cleanup_cache_prefix {#magento-cleanup_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L569) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L581) Cleanup cache id_prefix env files. @@ -761,7 +761,7 @@ After successful deployment, move the tmp_env.php file to env.php ready for next ### magento\:cron\:stop {#magento-cron-stop} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L585) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L597) Remove cron from crontab and kill running cron jobs. @@ -773,7 +773,7 @@ To use this feature, add the following to your deployer scripts: ### magento\:cron\:install {#magento-cron-install} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L601) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L613) Install cron in crontab. @@ -785,7 +785,7 @@ To use this feature, add the following to your deployer scripts: ### artifact\:prepare {#artifact-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L607) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L619) Prepares an artifact on the target server. @@ -805,7 +805,7 @@ This task is group task which contains next tasks: ### artifact\:finish {#artifact-finish} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L620) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L632) Executes the tasks after artifact is released. @@ -821,7 +821,7 @@ This task is group task which contains next tasks: ### artifact\:deploy {#artifact-deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L629) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L641) Actually releases the artifact deployment. From e732851fb9969832e20e11aa896c92b2d4d4c8c2 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 20:20:18 +0000 Subject: [PATCH 11/17] Fix style --- recipe/magento2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 41fec3cc1..d042f3496 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -133,7 +133,7 @@ }); set('config_import_needed_on_current', function () { - + if (!test('[ -d {{current_path}}/{{magento_dir}} ] && [ -f {{current_path}}/{{magento_dir}}/bin/magento ]')) { writeln('Current Magento installation is unavailable => import skipped'); return false; From 410ccc6e849a748e9a116cd922bff5d70bd60425 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 20:56:56 +0000 Subject: [PATCH 12/17] Generalize app config import log --- recipe/magento2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index d042f3496..f8545c620 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -351,7 +351,7 @@ function magentoDeployAssetsSplit(string $area) // do not use {{bin/magento}} as it must run on the current (last successful) release in failure scenarios run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:import --no-interaction'); } else { - writeln('App config is up to date => import skipped'); + writeln('App config import skipped'); } } catch (RunException $e) { writeln('Unable to import app config on current release => import skipped'); From 0493a505e500538cb2d416658795221c12241777 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 21:18:11 +0000 Subject: [PATCH 13/17] Handle run command Timeout exceptions. --- recipe/magento2.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index f8545c620..fddf9deb4 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -8,6 +8,7 @@ use Deployer\Exception\ConfigurationException; use Deployer\Exception\GracefulShutdownException; use Deployer\Exception\RunException; +use Deployer\Exception\TimeoutException; use Deployer\Host\Host; const CONFIG_IMPORT_NEEDED_EXIT_CODE = 2; @@ -143,8 +144,8 @@ // detect if app:config:import is needed on the current (live) release // do not use {{bin/magento}} as it resolves via release_or_current_path which is unreliable in failure scenarios run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:status'); - } catch (RunException $e) { - if ($e->getExitCode() == CONFIG_IMPORT_NEEDED_EXIT_CODE) { + } catch (RunException | TimeoutException $e) { + if ($e instanceof RunException && $e->getExitCode() == CONFIG_IMPORT_NEEDED_EXIT_CODE) { return true; } @@ -353,7 +354,7 @@ function magentoDeployAssetsSplit(string $area) } else { writeln('App config import skipped'); } - } catch (RunException $e) { + } catch (RunException | TimeoutException $e) { writeln('Unable to import app config on current release => import skipped'); } }); From 53b8cdbc08176c05c27b6afaaded3e9ac57c9b88 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 21:28:41 +0000 Subject: [PATCH 14/17] Generate docs --- docs/recipe/magento2.md | 122 ++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 503ba3f06..ac5b40c01 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -116,7 +116,7 @@ The magento2 recipe is based on the [common](/docs/recipe/common.md) recipe. ## Configuration ### static_content_locales -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L26) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L27) Configuration By default setup:static-content:deploy uses `en_US`. @@ -129,7 +129,7 @@ in you deployer script. ### magento_themes -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L43) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L44) Configuration You can also set the themes to run against. By default it'll deploy @@ -154,14 +154,14 @@ set('magento_themes', [ ### static_deploy_options -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L48) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L49) Static content deployment options, e.g. '--no-parent' ### split_static_deployment -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L51) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L52) Deploy frontend and adminhtml together as default @@ -171,7 +171,7 @@ false ### static_content_locales_backend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L54) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L55) Use the default languages for the backend as default @@ -181,7 +181,7 @@ Use the default languages for the backend as default ### magento_themes_backend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L58) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L59) backend themes to deploy. Only used if split_static_deployment=true This setting supports the same options/structure as [magento_themes](/docs/recipe/magento2.md#magento_themes) @@ -192,7 +192,7 @@ This setting supports the same options/structure as [magento_themes](/docs/recip ### static_content_jobs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L64) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L65) Configuration Also set the number of concurrent jobs to run. The default is 1 @@ -204,7 +204,7 @@ Update using: `set('static_content_jobs', '1');` ### content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L66) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L67) @@ -214,7 +214,7 @@ return time(); ### magento_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L71) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L72) Magento directory relative to repository root. Use "." (default) if it is not located in a subdirectory @@ -224,7 +224,7 @@ Magento directory relative to repository root. Use "." (default) if it is not lo ### shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L74) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L75) Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recipe/deploy/shared.php`. @@ -239,7 +239,7 @@ Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recip ### shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L78) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L79) Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`. @@ -265,7 +265,7 @@ Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/ ### writable_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L93) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L94) Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`. @@ -283,7 +283,7 @@ Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `r ### clear_paths -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L100) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L101) Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `recipe/deploy/clear_paths.php`. @@ -302,7 +302,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### bin/magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L112) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L113) WARNING: Do not use [bin/magento](/docs/recipe/magento2.md#bin/magento) in deploy:failed handlers - release_or_current_path points to the failed release during failure, not the live one. Use [current_path](/docs/recipe/common.md#current_path) explicitly instead. @@ -314,7 +314,7 @@ See: config_import_needed_on_current, magento:config:import:on-current, magento: ### magento_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L114) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L115) @@ -327,7 +327,7 @@ return $matches[0] ?? '2.0'; ### config_import_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L121) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L122) :::info Autogenerated @@ -338,7 +338,7 @@ The value of this configuration is autogenerated on access. ### config_import_needed_on_current -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L135) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L136) :::info Autogenerated @@ -349,7 +349,7 @@ The value of this configuration is autogenerated on access. ### database_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L158) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L159) :::info Autogenerated @@ -360,7 +360,7 @@ The value of this configuration is autogenerated on access. ### full_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L173) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L174) @@ -372,7 +372,7 @@ return false; ### upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L179) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L180) :::info Autogenerated @@ -383,7 +383,7 @@ The value of this configuration is autogenerated on access. ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L189) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L190) Deploy without setting maintenance mode if possible @@ -393,7 +393,7 @@ true ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L424) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L425) Artifact deployment section The file the artifact is saved to @@ -404,7 +404,7 @@ The file the artifact is saved to ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L427) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L428) The directory the artifact is saved in @@ -414,7 +414,7 @@ The directory the artifact is saved in ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L431) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L432) Points to a file with a list of files to exclude from packaging. The format is as with the `tar --exclude-from=[file]` option @@ -425,7 +425,7 @@ The format is as with the `tar --exclude-from=[file]` option ### build_from_repo -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L434) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L435) If set to true, the artifact is built from a clean copy of the project repository instead of the current working directory @@ -435,7 +435,7 @@ false ### repository -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L437) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L438) Overrides [repository](/docs/recipe/common.md#repository) from `recipe/common.php`. @@ -447,7 +447,7 @@ null ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L440) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L441) The relative path to the artifact file. If the directory does not exist, it will be created @@ -460,7 +460,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L448) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L449) The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings :::info Autogenerated @@ -471,14 +471,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L520) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L521) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L522) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L523) Array of shared directories that will be added to the default shared_dirs without overriding @@ -488,7 +488,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento\:compile {#magento-compile} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L199) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L200) Compiles magento di. @@ -501,7 +501,7 @@ e.g. ### magento\:deploy\:assets {#magento-deploy-assets} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L225) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L226) Deploys assets. @@ -528,7 +528,7 @@ in `app/etc/config.php`, e.g.: ### magento\:deploy\:assets\:adminhtml {#magento-deploy-assets-adminhtml} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L242) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L243) Deploys assets for backend only. @@ -536,7 +536,7 @@ Deploys assets for backend only. ### magento\:deploy\:assets\:frontend {#magento-deploy-assets-frontend} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L247) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L248) Deploys assets for frontend only. @@ -544,7 +544,7 @@ Deploys assets for frontend only. ### magento\:sync\:content_version {#magento-sync-content_version} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L310) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L311) Syncs content version. @@ -552,7 +552,7 @@ Syncs content version. ### magento\:maintenance\:enable {#magento-maintenance-enable} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L320) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L321) Enables maintenance mode. @@ -560,7 +560,7 @@ Enables maintenance mode. ### magento\:maintenance\:disable {#magento-maintenance-disable} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L326) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L327) Disables maintenance mode. @@ -568,7 +568,7 @@ Disables maintenance mode. ### magento\:maintenance\:enable-if-needed {#magento-maintenance-enable-if-needed} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L332) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L333) Set maintenance mode if needed. @@ -576,7 +576,7 @@ Set maintenance mode if needed. ### magento\:config\:import {#magento-config-import} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L339) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L340) Config Import. @@ -584,7 +584,7 @@ Config Import. ### magento\:config\:import\:on-current {#magento-config-import-on-current} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L348) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L349) Config Import on current release. @@ -592,7 +592,7 @@ Config Import on current release. ### magento\:upgrade\:db {#magento-upgrade-db} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L362) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L363) Upgrades magento database. @@ -600,7 +600,7 @@ Upgrades magento database. ### magento\:upgrade {#magento-upgrade} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L374) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L375) Run upgrades if needed. @@ -608,7 +608,7 @@ Run upgrades if needed. ### magento\:cache\:flush {#magento-cache-flush} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L383) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L384) Flushes Magento Cache. @@ -616,7 +616,7 @@ Flushes Magento Cache. ### deploy\:magento {#deploy-magento} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L388) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L389) Magento2 deployment operations. @@ -632,7 +632,7 @@ This task is group task which contains next tasks: ### magento\:build {#magento-build} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L397) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L398) Magento2 build operations. @@ -645,7 +645,7 @@ This task is group task which contains next tasks: ### deploy {#deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L403) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L404) Deploys your project. @@ -661,7 +661,7 @@ This task is group task which contains next tasks: ### deploy\:magento\:failed {#deploy-magento-failed} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L416) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L417) Run Magento post-deployment failure tasks. @@ -674,7 +674,7 @@ This task is group task which contains next tasks: ### artifact\:package {#artifact-package} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L459) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L460) Packages all relevant files in an artifact. @@ -682,7 +682,7 @@ tasks section ### artifact\:upload {#artifact-upload} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L469) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L470) Uploads artifact in release folder for extraction. @@ -690,7 +690,7 @@ Uploads artifact in release folder for extraction. ### artifact\:extract {#artifact-extract} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L474) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L475) Extracts artifact in release path. @@ -698,7 +698,7 @@ Extracts artifact in release path. ### build\:remove-generated {#build-remove-generated} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L480) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L481) Clears generated files prior to building. @@ -706,7 +706,7 @@ Clears generated files prior to building. ### build\:prepare {#build-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L485) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L486) Prepare local artifact build. @@ -714,7 +714,7 @@ Prepare local artifact build. ### artifact\:build {#artifact-build} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L510) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L511) Builds an artifact. @@ -731,7 +731,7 @@ This task is group task which contains next tasks: ### deploy\:additional-shared {#deploy-additional-shared} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L526) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L527) Adds additional files and dirs to the list of shared files and dirs. @@ -739,7 +739,7 @@ Adds additional files and dirs to the list of shared files and dirs. ### magento\:set_cache_prefix {#magento-set_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L541) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L542) Update cache id_prefix. @@ -753,7 +753,7 @@ after('deploy:magento', 'magento:cleanup_cache_prefix'); ### magento\:cleanup_cache_prefix {#magento-cleanup_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L581) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L582) Cleanup cache id_prefix env files. @@ -761,7 +761,7 @@ After successful deployment, move the tmp_env.php file to env.php ready for next ### magento\:cron\:stop {#magento-cron-stop} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L597) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L598) Remove cron from crontab and kill running cron jobs. @@ -773,7 +773,7 @@ To use this feature, add the following to your deployer scripts: ### magento\:cron\:install {#magento-cron-install} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L613) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L614) Install cron in crontab. @@ -785,7 +785,7 @@ To use this feature, add the following to your deployer scripts: ### artifact\:prepare {#artifact-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L619) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L620) Prepares an artifact on the target server. @@ -805,7 +805,7 @@ This task is group task which contains next tasks: ### artifact\:finish {#artifact-finish} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L632) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L633) Executes the tasks after artifact is released. @@ -821,7 +821,7 @@ This task is group task which contains next tasks: ### artifact\:deploy {#artifact-deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L641) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L642) Actually releases the artifact deployment. From da9bc25a96fb520d0b6d4195e5d2df0b2b7338af Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 21:34:03 +0000 Subject: [PATCH 15/17] Fix styling --- recipe/magento2.php | 1 - 1 file changed, 1 deletion(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index fddf9deb4..c4ad5a2c5 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -134,7 +134,6 @@ }); set('config_import_needed_on_current', function () { - if (!test('[ -d {{current_path}}/{{magento_dir}} ] && [ -f {{current_path}}/{{magento_dir}}/bin/magento ]')) { writeln('Current Magento installation is unavailable => import skipped'); return false; From 9f8ee6411a31490c54bc04de3c4a7c939d241184 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 21:37:28 +0000 Subject: [PATCH 16/17] generate docs --- docs/recipe/magento2.md | 88 ++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index ac5b40c01..60cf1619d 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -349,7 +349,7 @@ The value of this configuration is autogenerated on access. ### database_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L159) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L158) :::info Autogenerated @@ -360,7 +360,7 @@ The value of this configuration is autogenerated on access. ### full_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L174) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L173) @@ -372,7 +372,7 @@ return false; ### upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L180) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L179) :::info Autogenerated @@ -383,7 +383,7 @@ The value of this configuration is autogenerated on access. ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L190) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L189) Deploy without setting maintenance mode if possible @@ -393,7 +393,7 @@ true ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L425) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L424) Artifact deployment section The file the artifact is saved to @@ -404,7 +404,7 @@ The file the artifact is saved to ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L428) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L427) The directory the artifact is saved in @@ -414,7 +414,7 @@ The directory the artifact is saved in ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L432) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L431) Points to a file with a list of files to exclude from packaging. The format is as with the `tar --exclude-from=[file]` option @@ -425,7 +425,7 @@ The format is as with the `tar --exclude-from=[file]` option ### build_from_repo -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L435) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L434) If set to true, the artifact is built from a clean copy of the project repository instead of the current working directory @@ -435,7 +435,7 @@ false ### repository -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L438) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L437) Overrides [repository](/docs/recipe/common.md#repository) from `recipe/common.php`. @@ -447,7 +447,7 @@ null ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L441) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L440) The relative path to the artifact file. If the directory does not exist, it will be created @@ -460,7 +460,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L449) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L448) The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings :::info Autogenerated @@ -471,14 +471,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L521) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L520) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L523) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L522) Array of shared directories that will be added to the default shared_dirs without overriding @@ -488,7 +488,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento\:compile {#magento-compile} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L200) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L199) Compiles magento di. @@ -501,7 +501,7 @@ e.g. ### magento\:deploy\:assets {#magento-deploy-assets} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L226) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L225) Deploys assets. @@ -528,7 +528,7 @@ in `app/etc/config.php`, e.g.: ### magento\:deploy\:assets\:adminhtml {#magento-deploy-assets-adminhtml} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L243) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L242) Deploys assets for backend only. @@ -536,7 +536,7 @@ Deploys assets for backend only. ### magento\:deploy\:assets\:frontend {#magento-deploy-assets-frontend} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L248) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L247) Deploys assets for frontend only. @@ -544,7 +544,7 @@ Deploys assets for frontend only. ### magento\:sync\:content_version {#magento-sync-content_version} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L311) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L310) Syncs content version. @@ -552,7 +552,7 @@ Syncs content version. ### magento\:maintenance\:enable {#magento-maintenance-enable} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L321) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L320) Enables maintenance mode. @@ -560,7 +560,7 @@ Enables maintenance mode. ### magento\:maintenance\:disable {#magento-maintenance-disable} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L327) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L326) Disables maintenance mode. @@ -568,7 +568,7 @@ Disables maintenance mode. ### magento\:maintenance\:enable-if-needed {#magento-maintenance-enable-if-needed} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L333) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L332) Set maintenance mode if needed. @@ -576,7 +576,7 @@ Set maintenance mode if needed. ### magento\:config\:import {#magento-config-import} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L340) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L339) Config Import. @@ -584,7 +584,7 @@ Config Import. ### magento\:config\:import\:on-current {#magento-config-import-on-current} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L349) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L348) Config Import on current release. @@ -592,7 +592,7 @@ Config Import on current release. ### magento\:upgrade\:db {#magento-upgrade-db} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L363) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L362) Upgrades magento database. @@ -600,7 +600,7 @@ Upgrades magento database. ### magento\:upgrade {#magento-upgrade} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L375) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L374) Run upgrades if needed. @@ -608,7 +608,7 @@ Run upgrades if needed. ### magento\:cache\:flush {#magento-cache-flush} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L384) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L383) Flushes Magento Cache. @@ -616,7 +616,7 @@ Flushes Magento Cache. ### deploy\:magento {#deploy-magento} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L389) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L388) Magento2 deployment operations. @@ -632,7 +632,7 @@ This task is group task which contains next tasks: ### magento\:build {#magento-build} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L398) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L397) Magento2 build operations. @@ -645,7 +645,7 @@ This task is group task which contains next tasks: ### deploy {#deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L404) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L403) Deploys your project. @@ -661,7 +661,7 @@ This task is group task which contains next tasks: ### deploy\:magento\:failed {#deploy-magento-failed} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L417) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L416) Run Magento post-deployment failure tasks. @@ -674,7 +674,7 @@ This task is group task which contains next tasks: ### artifact\:package {#artifact-package} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L460) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L459) Packages all relevant files in an artifact. @@ -682,7 +682,7 @@ tasks section ### artifact\:upload {#artifact-upload} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L470) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L469) Uploads artifact in release folder for extraction. @@ -690,7 +690,7 @@ Uploads artifact in release folder for extraction. ### artifact\:extract {#artifact-extract} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L475) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L474) Extracts artifact in release path. @@ -698,7 +698,7 @@ Extracts artifact in release path. ### build\:remove-generated {#build-remove-generated} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L481) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L480) Clears generated files prior to building. @@ -706,7 +706,7 @@ Clears generated files prior to building. ### build\:prepare {#build-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L486) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L485) Prepare local artifact build. @@ -714,7 +714,7 @@ Prepare local artifact build. ### artifact\:build {#artifact-build} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L511) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L510) Builds an artifact. @@ -731,7 +731,7 @@ This task is group task which contains next tasks: ### deploy\:additional-shared {#deploy-additional-shared} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L527) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L526) Adds additional files and dirs to the list of shared files and dirs. @@ -739,7 +739,7 @@ Adds additional files and dirs to the list of shared files and dirs. ### magento\:set_cache_prefix {#magento-set_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L542) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L541) Update cache id_prefix. @@ -753,7 +753,7 @@ after('deploy:magento', 'magento:cleanup_cache_prefix'); ### magento\:cleanup_cache_prefix {#magento-cleanup_cache_prefix} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L582) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L581) Cleanup cache id_prefix env files. @@ -761,7 +761,7 @@ After successful deployment, move the tmp_env.php file to env.php ready for next ### magento\:cron\:stop {#magento-cron-stop} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L598) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L597) Remove cron from crontab and kill running cron jobs. @@ -773,7 +773,7 @@ To use this feature, add the following to your deployer scripts: ### magento\:cron\:install {#magento-cron-install} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L614) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L613) Install cron in crontab. @@ -785,7 +785,7 @@ To use this feature, add the following to your deployer scripts: ### artifact\:prepare {#artifact-prepare} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L620) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L619) Prepares an artifact on the target server. @@ -805,7 +805,7 @@ This task is group task which contains next tasks: ### artifact\:finish {#artifact-finish} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L633) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L632) Executes the tasks after artifact is released. @@ -821,7 +821,7 @@ This task is group task which contains next tasks: ### artifact\:deploy {#artifact-deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L642) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L641) Actually releases the artifact deployment. From 08466e74adcb007abd1c15bda9b74ba3550843d9 Mon Sep 17 00:00:00 2001 From: Carlos Reynosa Date: Fri, 15 May 2026 21:48:48 +0000 Subject: [PATCH 17/17] Fix styles --- recipe/magento2.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index c4ad5a2c5..caf767f15 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -143,7 +143,7 @@ // detect if app:config:import is needed on the current (live) release // do not use {{bin/magento}} as it resolves via release_or_current_path which is unreliable in failure scenarios run('{{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento app:config:status'); - } catch (RunException | TimeoutException $e) { + } catch (RunException|TimeoutException $e) { if ($e instanceof RunException && $e->getExitCode() == CONFIG_IMPORT_NEEDED_EXIT_CODE) { return true; } @@ -330,9 +330,9 @@ function magentoDeployAssetsSplit(string $area) desc('Set maintenance mode if needed'); task('magento:maintenance:enable-if-needed', function () { - ! get('enable_zerodowntime') || get('upgrade_needed') || get('config_import_needed') ? - invoke('magento:maintenance:enable') : - writeln('Config and database up to date => no maintenance mode'); + ! get('enable_zerodowntime') || get('upgrade_needed') || get('config_import_needed') + ? invoke('magento:maintenance:enable') + : writeln('Config and database up to date => no maintenance mode'); }); desc('Config Import'); @@ -353,7 +353,7 @@ function magentoDeployAssetsSplit(string $area) } else { writeln('App config import skipped'); } - } catch (RunException | TimeoutException $e) { + } catch (RunException|TimeoutException $e) { writeln('Unable to import app config on current release => import skipped'); } });