我已经使用shell访问设置了gitolite,并使用Capistrano将我的代码部署到生产环境中。问题是Capistrano将多个命令捆绑在一行中,使用换行符和gitolite进行安全检查,查找换行符并死掉。我不确定是否要从Capistrano或Gitolite方面解决这个问题。
我在运行'cap deploy'
时看到了这个错误executing "rm -rf /home/git/public_html/project/releases/20101129165633/log
/home/git/public_html/project/releases/20101129165633/public/system
/home/git/public_html/project/releases/20101129165633/tmp/pids &&\\\n
mkdir -p /home/git/public_html/project/releases/20101129165633/public &&\\\n
mkdir -p /home/git/public_html/project/releases/20101129165633/tmp &&\\\n ln -s /home/git/public_html/project/shared/log /home/git/public_html/project/releases/20101129165633/log &&\\\n ln -s /home/git/public_html/project/shared/system /home/git/public_html/project/releases/20101129165633/public/system &&\\\n ln -s /home/git/public_html/project/shared/pids /home/git/public_html/project/releases/20101129165633/tmp/pids"
servers: ["projectsite.com"]
[projectsite.com] executing command
错误消息:
** [out :: projectsite.com] I don't like newlines in the command: <COMMAND FROM ABOVE>
处理此问题的gitolite代码位于:https://github.com/sitaramc/gitolite/blob/pu/src/gl-auth-command
答案 0 :(得分:4)
你现在可能已经想到了这一点,但没有看到这个答案让我感到难过。
您可以使用"; "
加入多个命令,而不是换行符。以下是部署脚本示例:
role :server, "projectsite.com"
namespace :deploy do
desc "Does whatever beeudoublez wants"
task :default, :roles => :server, :except => { :no_release => true } do
run [ "rm -rf /home/git/public_html/project/releases/20101129165633/log /home/git/public_html/project/releases/20101129165633/public/system /home/git/public_html/project/releases/20101129165633/tmp/pids",
"mkdir -p /home/git/public_html/project/releases/20101129165633/public",
"mkdir -p /home/git/public_html/project/releases/20101129165633/public"].join("; ")
end
end