Search code examples
ruby-on-rails-3capistranogitolite

Newline issues with Capistrano and Gitolite


I've setup gitolite with shell access, and using Capistrano to deploy my code to production. The problem is that Capistrano bundles multiple commands in one line, using newlines and gitolite has a security check that looks for newlines, and dies. I'm not sure whether to tackle this from the Capistrano or Gitolite side.

I'm seeing this error from running '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

ERROR MESSAGE:

** [out :: projectsite.com] I don't like newlines in the command: <COMMAND FROM ABOVE>

The gitolite code that handles this is here: https://github.com/sitaramc/gitolite/blob/pu/src/gl-auth-command


Solution

  • You've probably figured this out by now, but not seeing an answer to this made me sad.

    Instead of newlines, you can join multiple commands with "; ". Here is an example deploy script:

    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