deployer
deployer copied to clipboard
Deployment breaks when done from different platforms (e.g. Windows and Mac)
-
Deployer version: 7.1.3
-
Deployment OS: Windows and Mac
Please, provide a minimal reproducible example of deploy.php
it can be any deploy.php which uses the default "deploy:release" task
Steps:
- do a deployment from Windows
- do a deployment of the same project from Mac to the same destination => Error: "undefined array key 2" in release.php on line 49
Explanation:
For each deployment, a line is added to the file .dep/release_log
This is done in vendor/deployer/deployer/recipe/deploy/release.php in line 126 with the following code
$json = escapeshellarg(json_encode($metainfo));
Unfortunately, in Windows, escapeshellarg replaces all double quotes in the string by spaces.
https://www.php.net/manual/en/function.escapeshellarg.php
This results for example in the following entry:
{ created_at : 2023-01-12T09:44:54+0000 , release_name : 7 , user : Firstname Lastname , target : HEAD }
When this line is read and parsed by deployer on a different OS (e.g. Mac), it can not be parsed.
It can only be parsed when the double quotes are contained:
{"created_at":"2023-01-12T09:44:54+0000","release_name":"7","user":"Firstname Lastname","target":"HEAD"}
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
I can confirm the problem. However, in my case it does not really seem to be related to the platform, as I always deploy from Windows and always from the Git Bash. Nevertheless, I ended up with a release_log like this:
{"created_at":"2022-12-20T11:29:41+0000","release_name":"1","user":"someusername","target":"somebranch"}
{"created_at":"2022-12-20T11:32:02+0000","release_name":"2","user":"someusername","target":"somebranch"}
{"created_at":"2022-12-20T11:44:52+0000","release_name":"3","user":"someusername","target":"somebranch"}
{"created_at":"2022-12-20T11:51:42+0000","release_name":"4","user":"someusername","target":"somebranch"}
{"created_at":"2022-12-20T13:43:35+0000","release_name":"5","user":"someusername","target":"somebranch"}
{ created_at : 2023-01-10T21:37:58+0000 , release_name : 6 , user : someusername , target : somebranch }
{ created_at : 2023-01-10T21:49:58+0000 , release_name : 7 , user : someusername , target : somebranch }
{ created_at : 2023-01-11T23:49:30+0000 , release_name : 8 , user : someusername , target : somebranch }
{ created_at : 2023-01-18T14:52:12+0000 , release_name : 9 , user : someusername , target : somebranch }
{ created_at : 2023-01-19T17:58:19+0000 , release_name : 10 , user : someusername , target : somebranch }
{ created_at : 2023-01-30T11:40:20+0000 , release_name : 11 , user : someusername , target : somebranch }
{"created_at":"2023-02-03T14:20:05+0000","release_name":"12","user":"Firstname Lastname","target":"somebranch"}
which currently breaks deployment.
Looks like problem is with usage of escapeshell.
I have no clue how to fix it, so I asked the community:
https://phpc.social/@Schrank/109812249564590328 https://twitter.com/Fabian_ikono/status/1622220417359400960
Hope this helps :-)
P.S. I can't reproduce it on mac (12.6.1 (21G217)) in the current version (Deployer 7.1.3)
I know how to fix it. The same way I did in google/zx.
Like this? https://github.com/google/zx/blob/691e6cb01cae7c046bad2fdf5535c2a9ba6e87f3/src/util.ts#L35-L48
Cool, taking notes
Yes)