In Laravel 5.8 using envoy I want to set the password of a user in console command, like
envoy run Deploy --serveruser_password=mypass1112233
Having in envoy file:
@setup
$server_login_user= 'serveruser';
$user_password = isset($serveruser_password) ? $serveruser_password : "Not Defined";
@endsetup
@task( 'clone_project', ['on'=>$on] )
echo '$user_password password ::';
echo $user_password;
But $user_password output empty in both cases : 1) if serveruser_password is set in command
envoy run Deploy --serveruser_password=mypass1112233
2) or it is empty
envoy run Deploy
But I expected "Not Defined" outputted...
Why error and how correct?
Try the following.
@setup
$server_login_user = 'serveruser';
$user_password = isset($serveruser_password) ? $serveruser_password : 'Not Defined';
@endsetup
@servers(['local' => '127.0.0.1'])
@macro('deploy')
clone_project
@endmacro
@task('clone_project')
echo 'The password is: {{ $user_password }}.';
@endtask
Please make sure your macro is named "deploy" and not "Deploy." Also, in your echo statement, use curly braces to echo out your set variable. The output will be as follows.
$ envoy run deploy --serveruser_password=mypass1112233
[127.0.0.1]: The password is: mypass1112233.
$ envoy run deploy
[127.0.0.1]: The password is: Not Defined.