Capistrano 3/SSHKit写入自定义任务中的文件

ast*_*nic 7 ruby git deployment capistrano3 sshkit

我想用我的版本号标记当前部署的目录.

我试过这种方法:

获取本地应用程序版本,将其存储到变量中,并在远程主机上将其存储在文件中.

namespace :deploy do
  desc "Set a release number as the app version"
  task :mark_release do
    release_number = `git describe`
      on roles(:web) do
        execute("echo #{release_number} > #{current_path}/RELEASE")
      end
    end
  end
Run Code Online (Sandbox Code Playgroud)

问题是,当我通过以下方式运行时:

cap deploy:mark_release
Run Code Online (Sandbox Code Playgroud)

命令看起来像这样:

echo v9.3.0-254-g178d1f8; > /foo/bar/current/RELEASE
Run Code Online (Sandbox Code Playgroud)

分号正在制造麻烦.我的RELEASE文件当然是空的.

我认为这是由于SSHKit的一些转义.

有线索吗?

ast*_*nic 4

我成功了:

1)我从机器上的repo目录中获取了版本号

2)我通过上传将其用流写入文件!方法

namespace :deploy do
 desc "Set a release number as the app version"
 task :mark_release do
   on roles(:web) do
     within "/foo/bar/repo/" do
       upload! StringIO.new(capture(:git, "describe")), "#{current_path}/RELEASE"
     end
   end
 end
end
Run Code Online (Sandbox Code Playgroud)