Ric*_*ape 5 ruby deployment capistrano capistrano3
我是卡皮斯特拉诺(第3.2.1节)的绝对新手,所以请原谅我,错误,无用.我正在部署一个PHP应用程序并希望在deploy:symlink:release任务之前运行composer install(仅在不运行回滚时)
我无法访问新创建的发布目录,因为我需要它才能进入它并运行composer(并运行其他一些项目).我现在有;
namespace :deploy do
namespace :symlink do
desc 'Run composer'
task :runcomposer do
on roles :all do
execute "cd '#{current_release}' && composer install"
execute "cd '#{current_release}' && ln -s /sites/shared/index.php index.php"
end
end
before :release, :runcomposer
end
end
Run Code Online (Sandbox Code Playgroud)
{current_release}变量此时似乎不存在(这很奇怪,因为运行git pull的目录肯定是在/ releases /目录中创建的(带有适当的时间戳)但是我得到'未定义的局部变量或方法"current_release"'
有没有办法在'当前'符号链接指向它之前确定这个新版本目录?非常感谢你提前.
我将此作为对我的问题的评论,但目前,这是我能找到的唯一答案,因此我将其提升为答案;
好的,所以我已经确定了一种可能的方法来做到这一点,但这看起来很糟糕。即使对于像我这样的初学者:
newreleasedir = capture('ls -t /sites/releases | head -1')
Run Code Online (Sandbox Code Playgroud)
然后
execute "cd /sites/releases/#{newreleasedir} && composer install"
Run Code Online (Sandbox Code Playgroud)
有人请告诉我这太可怕了以及我应该如何做:)