deployphp / deployer

The PHP deployment tool with support for popular frameworks out of the box
https://deployer.org
MIT License
10.41k stars 1.47k forks source link

Git Error During Deployment #3804

Open thinkcube-solutions opened 2 months ago

thinkcube-solutions commented 2 months ago
<?php
namespace Deployer;

require 'recipe/common.php';

// Config
set('repository', 'git@github.com:thinkcube-solutions/deployer-7-testing.git');

set('http_user', 'deployer');

add('shared_files', []);
add('shared_dirs', []);
add('writable_dirs', []);

set('allow_anonymous_stats', false);
set('git_tty', true);
set('git_ssh_command', 'ssh');

// Set writeable mode to ACL
set('writable_mode', 'acl');

// Hosts
host('deployer_host')
    ->set('branch', 'main')
    ->set('remote_user', 'deployer')
    ->set('deploy_path', '/var/www/deployer-7-testing');

When deploying a simple config based on the above, the following error occours when the update_code task is run by Deployer:

[deployer_host] run export GIT_TERMINAL_PROMPT='0' GIT_SSH_COMMAND='ssh'; [ -f /var/www/deployer-7-testing/.dep/repo/HEAD ] || /usr/bin/git clone --mirror git@github.com:thinkcube-solutions/deployer-7-testing.git /var/www/deployer-7-testing/.dep/repo 2>&1
[deployer_host] 
[deployer_host] bash: line 1: syntax error near unexpected token `$'B\E[m/usr/bin/git''
[deployer_host] bash: line 1: `( export GIT_TERMINAL_PROMPT='0' GIT_SSH_COMMAND='ssh'; [ -f /var/www/deployer-7-testing/.dep/repo/HEAD ] || /usr/bin/git clone --mirror git@github.com:thinkcube-solutions/deployer-7-testing.git /var/www/deployer-7-testing/.dep/repo 2>&1 ); printf '' $?;'
[deployer_host]  error  in update_code.php on line 90:
[deployer_host] exit code -1 (Unknown error)
done deploy:update_code 2s 28ms
ERROR: Task deploy:update_code failed!
task deploy:failed
[deployer_host] /home/linuxbrew/.linuxbrew/Cellar/php@8.2/8.2.13/bin/php /home/user/Lab/deployer-7-testing/vendor/deployer/deployer/dep worker --port 38861 --task deploy:failed --host deployer_host --decorated -vvv
done on deployer_host
done deploy:failed 61ms

Upvote & Fund

Fund with Polar

Schrank commented 2 months ago

Good morning!

What happens if you remove git_ssh_command?

i would assume, that either there are weird whitespaces or the server has a broken configuration?

you can copy the commands submitted and run them individually. That helps me often to identify issues.

thinkcube-solutions commented 2 months ago

Good morning!

What happens if you remove git_ssh_command?

i would assume, that either there are weird whitespaces or the server has a broken configuration?

you can copy the commands submitted and run them individually. That helps me often to identify issues.

Good morning, @Schrank

I have removed the following line:

set('git_ssh_command', 'ssh');

However, the same error still pops up as before. How can I go about copying the commands individually and running them so I can provide you with more info?

I should also note, that everything works just fine on my Deployer 6 sites. Only version 7 is having this issue.

Schrank commented 2 months ago

Adding -vv shows you the commands, then you can copy them.

thinkcube-solutions commented 2 months ago

Thanks @Schrank !

Here is the terminal output.

➜ dep7 deploy staging -vv
task deploy:info
[staging] info deploying main
done on staging
done deploy:info 92ms
task deploy:setup
[staging] run [ -d /var/www/deployer-7-testing ] || mkdir -p /var/www/deployer-7-testing;
cd /var/www/deployer-7-testing;
[ -d .dep ] || mkdir .dep;
[ -d releases ] || mkdir releases;
[ -d shared ] || mkdir shared;
[staging] 
[staging] run if [ ! -L /var/www/deployer-7-testing/current ] && [ -d /var/www/deployer-7-testing/current ]; then echo +correct; fi
[staging] 
done on staging
done deploy:setup 1s 243ms
task deploy:lock
[localhost] run git config --get user.name
[localhost] thinkcube-solutions
[staging] run [ -f /var/www/deployer-7-testing/.dep/deploy.lock ] && echo +locked || echo 'thinkcube-solutions' > /var/www/deployer-7-testing/.dep/deploy.lock
[staging] 
[staging] +locked
done on staging
done deploy:lock 698ms
task deploy:release
[staging] run cd /var/www/deployer-7-testing && (if [ -h release ]; then echo +legitimate; fi)
[staging] 
[staging] +legitimate
[staging] run cd /var/www/deployer-7-testing && (if [ -d releases ] && [ "$(ls -A releases)" ]; then echo +legitimate; fi)
[staging] 
[staging] +legitimate
[staging] run cd /var/www/deployer-7-testing && (cat .dep/latest_release || echo 0)
[staging] 
[staging] 1
[staging] run cd /var/www/deployer-7-testing && (if [ -d releases/1 ]; then echo +right; fi)
[staging] 
[staging] +right
[staging] run cd /var/www/deployer-7-testing && (echo 1 > .dep/latest_release)
[staging] 
[staging] run cd /var/www/deployer-7-testing && (echo '{"created_at":"2024-04-09T11:28:59+0000","release_name":"1","user":"thinkcube-solutions","target":"main"}' >> .dep/releases_log)
[staging] 
[staging] run cd /var/www/deployer-7-testing && (mkdir -p releases/1)
[staging] 
[staging] run cd /var/www/deployer-7-testing && ((man ln 2>&1 || ln -h 2>&1 || ln --help 2>&1) | grep -- --relative || true)
[staging] 
[staging]        -r, --relative
[staging] run cd /var/www/deployer-7-testing && (ln -nfs --relative releases/1 /var/www/deployer-7-testing/release)
[staging] 
done on staging
done deploy:release 5s 522ms
task deploy:update_code
[staging] run command -v 'git' || which 'git' || type -p 'git'
[staging] 
[staging] /usr/bin/git
[staging] run [ -d /var/www/deployer-7-testing/.dep/repo ] || mkdir -p /var/www/deployer-7-testing/.dep/repo
[staging] 
[staging] run export GIT_TERMINAL_PROMPT='0' GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=accept-new'; [ -f /var/www/deployer-7-testing/.dep/repo/HEAD ] || /usr/bin/git clone --mirror git@github.com:thinkcube-solutions/deployer-7-testing.git /var/www/deployer-7-testing/.dep/repo 2>&1
[staging] 
[staging] bash: line 1: syntax error near unexpected token `$'B\E[m/usr/bin/git''
[staging] bash: line 1: `( export GIT_TERMINAL_PROMPT='0' GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=accept-new'; [ -f /var/www/deployer-7-testing/.dep/repo/HEAD ] || /usr/bin/git clone --mirror git@github.com:thinkcube-solutions/deployer-7-testing.git /var/www/deployer-7-testing/.dep/repo 2>&1 ); printf '' $?;'
[staging]  error  in update_code.php on line 90:
[staging] exit code -1 (Unknown error)
done deploy:update_code 2s 63ms
ERROR: Task deploy:update_code failed!
task deploy:failed
done on staging
done deploy:failed 91ms