I have a PHP Deployer task to recursively change file owner of everything in the deploy path:
task('set_owner', function () {
run("chown -R someuser:www-data {{deploy_path}}");
});
after('deploy:failed', 'deploy:unlock'); // Unlock after failed deploy
Deployer failed on this task since there are some Operation not permitted
errors given by this commond. Fair enough, since those files don't need changing anyway. So I add 2>&1 | grep -v 'Operation not permitted'
to prevent the errors from showing:
task('set_owner', function () {
run("chown -R deployer:www-data {{deploy_path}} 2>&1 | grep -v 'Operation not permitted'");
});
after('deploy:failed', 'deploy:unlock'); // Unlock after failed deploy
However when I run it Deployer still fails on this task:
➤ Executing task set_owner
[myapp.com] > chown -R someuser:www-data /var/www/myapp.com 2>&1 | grep -v 'Operation not permitted'
➤ Executing task deploy:failed
• done on [myapp.com]
✔ Ok [1ms]
➤ Executing task deploy:unlock
[myapp.com] > rm -f /var/www/myapp.com/.dep/deploy.lock
• done on [myapp.com]
✔ Ok [1s 364ms]
In Client.php line 103:
[Deployer\Exception\RuntimeException (1)]
The command "chown -R someuser:www-data /var/www/myapp.com 2>&
1 | grep -v 'Operation not permitted'" failed.
Exit Code: 1 (General error)
Is there a way to prevent Deployer from failing in this case?