Giter Site home page Giter Site logo

git-deploy's Introduction

Easy git deployment

Straightforward, Heroku-style, push-based deployment. Your deploys can become as simple as this:

$ git push production master

To get started, install the "git-deploy" gem.

gem install git-deploy

Only the person who is setting up deployment for the first time needs to install the gem. You don't have to add it to your project's Gemfile.

Which app languages/frameworks are supported?

Regardless of the fact that this tool is mostly written in Ruby, git-deploy can be useful for any kind of code that needs deploying on a remote server. The default scripts are suited for Ruby web apps, but can be edited to accommodate other frameworks.

Your deployment is customized with per-project callback scripts which can be written in any language.

The assumption is that you're deploying to a single host to which you connect over SSH using public/private key authentication.

Initial setup

  1. Create a git remote for where you'll push the code on your server. The name of this remote in the examples is "production", but it can be whatever you wish ("online", "website", or other).

    git remote add production "[email protected]:/apps/mynewapp"

    /apps/mynewapp is the directory where you want your code to reside on the remote server. If the directory doesn't exist, the next step creates it.

  2. Run the setup task:

    git deploy setup -r "production"

    This will initialize the remote git repository in the deploy directory (/apps/mynewapp in the above example) and install the remote git hook.

  3. Run the init task:

    git deploy init

    This generates default deploy callback scripts in the deploy/ directory. You should check them in git because they are going to be executed on the server during each deploy.

  4. Push the code.

    git push production master
  5. Login to your server and manually perform necessary one-time administrative operations. This might include:

    • set up the Apache/nginx virtual host for this application;
    • check your config/database.yml and create the production database.

Everyday deployments

If you've set your app correctly, visiting http://example.com in your browser should show it up and running.

Now, subsequent deployments are done simply by pushing to the branch that is currently checked out on the remote:

git push production master

Because the deployments are performed with git, nobody else on the team needs to install the "git-deploy" gem.

On every deploy, the default deploy/after_push script performs the following:

  1. updates git submodules (if there are any);
  2. runs bundle install --deployment if there is a Gemfile;
  3. runs rake db:migrate if new migrations have been added;
  4. clears cached CSS/JS assets in "public/stylesheets" and "public/javascripts";
  5. restarts the web application.

You can customize all this by editing generated scripts in the deploy/ directory of your app.

Deployments are logged to log/deploy.log in your application's directory.

How it works

The git deploy setup command installed a post-receive git hook in the remote repository. This is how your code on the server is kept up to date. This script checks out the latest version of your project from the current branch and runs the following callback scripts:

  • deploy/setup - on first push.
  • deploy/after_push - on subsequent pushes. It in turn executes:
    • deploy/before_restart
    • deploy/restart
    • deploy/after_restart
  • deploy/rollback - executed for git deploy rollback.

All of the callbacks are optional. These scripts are ordinary Unix executables. The ones which get generated for you by git deploy init are written in shell script and Ruby.

Extra commands

  • git deploy hooks - Updates git hooks on the remote repository

  • git deploy log [N=20] - Shows last 20 lines of deploy log on the server

  • git deploy rerun - Re-runs the deploy/after_push callback as if a git push happened

  • git deploy restart - Runs the deploy/restart callback

  • git deploy rollback - Undo a deploy by checking out the previous revision, runs deploy/rollback if exists instead of deploy/after_push

  • git deploy upload <files> - Copy local files to the remote app

git-deploy's People

Contributors

blt avatar ddazza avatar gregnavis avatar guilleiguaran avatar henrikbjorn avatar jakubkouba avatar kerryb avatar mislav avatar nstielau avatar reednj avatar rpavlik avatar scott-steadman avatar til avatar yannlugrin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-deploy's Issues

Could not find 'bundler' (using RVM)

Hey. I get

...
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 433 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: HEAD is now at c8025c8 fixing
remote: files changed: 1
remote: /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'bundler' (>= 0) among 8 total gem(s) (Gem::LoadError)
remote:     from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
remote:     from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
remote:     from /usr/local/rvm/gems/ruby-2.1.0@global/bin/bundle:22:in `<main>'
remote:     from /usr/local/rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
remote:     from /usr/local/rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'
To ...

after I run 'git push production master' command. I'm using ruby over RVM.

git deploy setup seems stuck?

Sorry if this is a silly question, when I run 'git deploy setup' the script seems to hang. I'm deploying to a mac running os x server. Any suggestions are appreciated...

ricsrok$ git deploy setup -r production
[production] $ sudo -p 'sudo password: ' mkdir -p /Users/admin/sites/newrev && \
  sudo -p 'sudo password: ' chown $USER /Users/admin/sites/newrev
  sudo password: [local] $ stty raw -echo -icanon isig

Can't do initial setup

I keep getting a "Error parsing remote url" error when doing the initial "git deploy setup". I've tried changing the format of the git remote url every which way, but nothing seems to work. I even finally used something of the "www.example.com/home/user/directory" format, and that didn't work either.

Suggestions for documentation

I have to say @mislav - I tried this little gem out tonight, and it's absolutely amazing. Forget Capistrano.

However, I did want to patch a few notes your way to add to the readme, if you so desire:

git deploy hooks and other git deploy ... commands should be suffixed with -r production or whatever the repo name is; otherwise it uses origin.

deploy/restart should always be updated depending on the server. I run unicorn, not passenger, and I was wondering for a few minutes why the server didn't restart. Duh, but this note might save someone some time.

Verbose output: personally, I could care less about a log file on the server - I would rather have the information displayed right away, as it really doesn't tell you what's going on. I did the following to display all the goodness right in the console:

On the remote server, go to /your/app/path/.git/hooks and open up post-receive in your editor. At the bottom of the file, change the line:
[ -x deploy/after_push ] && nohup deploy/after_push $oldrev $newrev 1>>$logfile 2>>$logfile &
to:
[ -x deploy/after_push ] && nohup deploy/after_push $oldrev $newrev
and bundling, asset compilation, migrations, etc. will all be displayed.

Again, killer job on this gem. I will definitely be using it a heck of a lot more often.

Commands should not need to be run by sudo

We're in the process of locking our projects down, and we've setup our own infrastructure. We found git-deploy and figured it would be a great fit, until re realised that we had to give users sudo to setup the folder structure.etc.

Is there any reason as to why this is the case? Is there any way to switch that off or ensure that git-deploy does NOT use sudo for setup?

Use different environments

Is it possible to use git-deploy for different Rails environments on the same server? I am currently using git-deploy to deploy to my server in a production environment. I would also like to create a staging environment on the same server but have no idea how to use/setup git-deploy to also deploy to the staging environment in parallel.

Init, doesn't create /deploy ?

HI,

I've been testing Git for deployment by adding a remote location that is setup as --bare to my local environment and using git to push! I found about git-deploy recently and installed right away. While testing it, I noticed that a /deploy directory isn't created. Why would that happen if I followed the tutorial ? Something going wrong ?

Thanks for looking!

Separate set of callback scripts per deployment target?

What's the best way to customize the callback scripts per deployment target? Currently, it seems that all targets share the same deploy/after_push, deploy/before_restart, etc. by default.

Maybe change the git deploy setup -r and git deploy ini commands so that separate subdirectories are created to store callback scripts for each deployment target? So we can have, e.g.:

  • deploy/production/after_push, deploy/production/before_restart
  • deploy/staging/after_push, deploy/production/before_restart

Of course, that means git deploy setup -r needs to customize the post-receive hook so that callback scripts from the correct subdirectory will be used on each deployment target.

Our use case is that we have two deployment targets hosted by the same machine, and each deployment target has its own Python virtualenv (the Ruby counterpart would be Bundler, probably). And we want to update the deployment target's virtualenv in the after_push.

Does this sound like a legitimate use case? Or are we doing things wrong?

I can probably dig into the post-receive hook on each deployment target after it has been installed, but having git deploy setup -r automate this seems more convenient.

Deploy of the branch other than master fails

My deploy goes fine when I try to deploy master branch following the setup instructions.
But when I try to deploy the "russian" branch of my app, it seems to push code to app host:

MacBook-Pro-Vitaly:oh vitaly$ git remote add production [email protected]:/home/rails

MacBook-Pro-Vitaly:oh vitaly$ git deploy setup -r production
[production] $ chmod g+ws /home/rails && \
  cd /home/rails && \
  git init --shared && \
  git config --bool receive.denyNonFastForwards false && \
  git config receive.denyCurrentBranch ignore
Initialized empty shared Git repository in /home/rails/.git/
FILE: [local] hooks/post-receive.sh  ->  [production] /home/rails/.git/hooks/post-receive
[production] $ chmod +x /home/rails/.git/hooks/post-receive

MacBook-Pro-Vitaly:oh vitaly$ git deploy init
      create  deploy/after_push
       chmod  deploy/after_push
      create  deploy/restart
       chmod  deploy/restart
      create  deploy/before_restart
       chmod  deploy/before_restart

MacBook-Pro-Vitaly:oh vitaly$ git push production russian
Counting objects: 37587, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9618/9618), done.
Writing objects: 100% (37587/37587), 19.98 MiB | 857 KiB/s, done.
Total 37587 (delta 27359), reused 37564 (delta 27348)
To [email protected]:/home/rails
 * [new branch]      russian -> russian

But the app directory is actually empty on the app host:

rails@apphost:~$ ls -la
total 40
drwxrwsr-x 6 rails rails 4096 Nov 19 11:12 .
drwxr-xr-x 5 root  root  4096 Nov 18 12:27 ..
-rw------- 1 rails rails 1864 Nov 19 09:20 .bash_history
-rw-r--r-- 1 rails rails  220 Nov 18 11:49 .bash_logout
-rw-r--r-- 1 rails rails 3184 Nov 18 11:49 .bashrc
drwxrwsr-x 8 rails rails 4096 Nov 19 11:13 .git
-rw-r--r-- 1 rails rails  675 Nov 18 11:49 .profile
drwxr-xr-x 2 rails rails 4096 Nov 18 20:43 .ssh

$PATH not detected

I installed ruby to user's home directory using ruby-install.
I set up the $PATH info to my .bashrc and i add sourcing .bashrc to my .bash_profile as follows:

(in .bashrc)

export PATH=~/.rubies/default/bin:$PATH

(in .bash_profile)

if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi

And then when i run git push on my local machine, it seems that any script not triggered. $PATH does not affected.

Actually when i run gut deploy rerun instead of git push, it works well. The $PATH applied successfully.

Is there any difference between git push and git deploy rerun?
Why not work bashrc and bash_profile when running git push?

Windows: `git deploy` won't work, but git-deploy will

Hi, not sure what is happening, not a ruby guy, working fine on my mac, but windows install doesn't work when I try git deploy I get....

fatal: 'deploy' appears to be a git command, but we were not
able to execute it. Maybe git-deploy is broken?

but if i use git-deploy directly it works ok.

I guess a ruby path issue or something? not a big deal but do you know what the problem might be?

Cannot setup via SSH (AuthenticationFailed error)

I set up my remote for deploy using

$ git remote add production "ssh://userAAA@server:port/web/dir"

While running

$ git deploy setup -r "production"

I get the following error:

gems/net-ssh-2.6.8/lib/net/ssh.rb:207:in `start': userAAA (Net::SSH::AuthenticationFailed)
    from gems/git-deploy-0.6.0/lib/git_deploy/ssh_methods.rb:96:in `ssh_connection'
    from gems/git-deploy-0.6.0/lib/git_deploy/ssh_methods.rb:43:in `ssh_exec'
    from gems/git-deploy-0.6.0/lib/git_deploy/ssh_methods.rb:35:in `run_test'
    from gems/git-deploy-0.6.0/lib/git_deploy.rb:28:in `setup'
    from gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
    from gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    from gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
    from gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
    from gems/git-deploy-0.6.0/bin/git-deploy:3:in `<top (required)>'
    from bin/git-deploy:23:in `load'
    from bin/git-deploy:23:in `<main>'

Re-run deploy after failure

If the git push succeeds but somethings goes wrong with the deploy, there should be a way to re-run the hook scripts.

Git submodule init and update

It would be great if the submodules could be init'd and updated on post-receive. It could first check for the presence of the .gitmodules file.

before_restart problem

in my log/deploy.log i am getting

==== Fri Jun 21 04:44:49 UTC 2013 ====
files changed: 1
/usr/bin/env: ruby: No such file or directory

not sure why its doing that I've installed ruby using rbenv and running it in the terminal (logged in via ssh) seems to work.

New deploy wipes all files

First, cap deploy:setup doesn't work as expected:

 * executing `deploy:setup'
  * executing "sudo -p 'sudo password: ' mkdir -p ~/app && sudo -p 'sudo password: ' chown $USER ~/app && cd ~/app && git init  && git config receive.denyCurrentBranch ignore"
    servers: ["xxx"]
    [livrenoir@xxx] executing command
*** [err :: livrenoir@xxx] sudo: no tty present and no askpass program specified
    command finished
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' mkdir -p ~/app && sudo -p '\\''sudo password: '\\'' chown $USER ~/app && cd ~/app && git init  && git config receive.denyCurrentBranch ignore'" on livrenoir@xxx

So I ran the comman manually mkdir -p ~/app && cd ~/app && git init && git config receive.denyCurrentBranch ignore and then cap deploy

  * executing `deploy'
  * executing `deploy:push'
Counting objects: 3276, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (1316/1316), done.
Writing objects: 100% (3276/3276), 900.02 KiB, done.
Total 3276 (delta 1935), reused 3204 (delta 1870)
To livrenoir@xxx:~/app
 * [new branch]      master -> master

A new cap deploy returns this:

  * executing `deploy'
  * executing `deploy:push'
Everything up-to-date

If I go into the app folder, and do a git status this is what I see:

git status
# On branch master
# Changed but not updated:
#   (use "git add/rm ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#   deleted:    .gitignore
#   deleted:    .rspec
#   deleted:    Gemfile
#   deleted:    Gemfile.lock
#   deleted:    README.md
#   deleted:    Rakefile
#   ...
no changes added to commit (use "git add" and/or "git commit -a")

And that's it, all files have been "magically" deleted! I did a git reset --hard HEAD and then all is fine, but on all subsequent pushes the new files get deleted.

I'm on Ubuntu 10.04 LTS & git 1.7.0.4

permission denied on push?

When I push to my server, I'm getting a Permission denied error when trying to run deploy/after_push. Manually setting chmod 0744 deploy/* works (I'm able to run deploy/after_push manually) until i push changes again through git and get the same error.

Anyone know what the issue might be?

Here is my deploy log - deploy/after_push doesn't seem to be running or producing any output:

==== Sun Jul 14 02:38:40 UTC 2013 ====
==== Sun Jul 14 02:40:03 UTC 2013 ====
==== Sun Jul 14 02:43:42 UTC 2013 ====
==== Sun Jul 14 05:59:08 UTC 2013 ====

delpoy without commit

thanks for your work.

I wanna to know how to git push delpoy without commit, simmlar rsync

using bare repository ?

Could there be an option for creating a bare repository remote on setup and having the post deploy hook, update an additional dir?

something like this :

mkdir production.git
git init --bare production.git 
git clone production.git production

Then on post update hook:

#update changes to working directory 
GIT_WORK_TREE=production git checkout -f

Old net-ssh version in gemspec

When running git-deploy with an .ssh/config that restricts the ciphers (following https://stribika.github.io/2015/01/04/secure-secure-shell.html ), the connection fails with an "unsupported encryption algorithm" error:

$ git-deploy setup -r production
/home/tils/.gem/ruby/2.2.2/gems/net-ssh-2.6.8/lib/net/ssh/transport/algorithms.rb:216:in `block in prepare_preferred_algorithms!': unsupported encryption algorithm: `[email protected]' (NotImplementedError)
        from /home/tils/.gem/ruby/2.2.2/gems/net-ssh-2.6.8/lib/net/ssh/transport/algorithms.rb:209:in `each'
        from /home/tils/.gem/ruby/2.2.2/gems/net-ssh-2.6.8/lib/net/ssh/transport/algorithms.rb:209:in `prepare_preferred_algorithms!'
        from /home/tils/.gem/ruby/2.2.2/gems/net-ssh-2.6.8/lib/net/ssh/transport/algorithms.rb:120:in `initialize'
        from /home/tils/.gem/ruby/2.2.2/gems/net-ssh-2.6.8/lib/net/ssh/transport/session.rb:80:in `new'
        from /home/tils/.gem/ruby/2.2.2/gems/net-ssh-2.6.8/lib/net/ssh/transport/session.rb:80:in `initialize'
        from /home/tils/.gem/ruby/2.2.2/gems/net-ssh-2.6.8/lib/net/ssh.rb:192:in `new'
        from /home/tils/.gem/ruby/2.2.2/gems/net-ssh-2.6.8/lib/net/ssh.rb:192:in `start'
        from /home/tils/.gem/ruby/2.2.2/gems/git-deploy-0.6.1/lib/git_deploy/ssh_methods.rb:96:in `ssh_connection'
        from /home/tils/.gem/ruby/2.2.2/gems/git-deploy-0.6.1/lib/git_deploy/ssh_methods.rb:43:in `ssh_exec'
        from /home/tils/.gem/ruby/2.2.2/gems/git-deploy-0.6.1/lib/git_deploy/ssh_methods.rb:35:in `run_test'
        from /home/tils/.gem/ruby/2.2.2/gems/git-deploy-0.6.1/lib/git_deploy.rb:28:in `setup'
        from /home/tils/.gem/ruby/2.2.2/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
        from /home/tils/.gem/ruby/2.2.2/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
        from /home/tils/.gem/ruby/2.2.2/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
        from /home/tils/.gem/ruby/2.2.2/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
        from /home/tils/.gem/ruby/2.2.2/gems/git-deploy-0.6.1/bin/git-deploy:3:in `<top (required)>'
        from /home/tils/.gem/ruby/2.2.2/bin/git-deploy:23:in `load'
        from /home/tils/.gem/ruby/2.2.2/bin/git-deploy:23:in `<main>'

When I try to connect with net-ssh manually in irb, with the latest net-ssh Version 2.9.1, it works. Is the restrictive setting in the git-deploy gemspec of '~> 2.6.6' on purpose, or could it be changed to just '~> 2.6'?

Same goes for net-scp I suppose.

git deploy is not a git command

I've installed following the instructions, but when I execute git deploy, it shows me the message: git: 'deploy' is not a git command. See 'git --help'.

do you have any clue about this issue??

Seems to require absolute path in remote

Relative paths in the remote specification (i.e. starting from $HOME) should be left unharmed. Currently, git deploy setup appears to add a '/' before the path, which will break any relative path.

post-receive not run on first deploy

This might be a Git issue, but the post-receive hook is not run after first deploy.

How to reproduce:

host1$ git deploy setup -r staging
host1$ git push staging master

At this point the log/deploy.log is empty. But when follow this with:

staging$ git reset --hard HEAD^
host1$ git fetch staging
host1$ git push staging master

Then the post-receive hook is run and everything is ok.

Can this be because git post-receive hook expects two revisions as input, but initially there is only one?

Alternate checkout path

If I want to use gitlab on my dev server and have a free github-like gui via gitlab, I would like to keep all my repos in eg. /home/repos, and have them check out the working tree in according public_html folder
Meaning if I have a repo at home/repos/myweb.git , I would like to check out master branch to /home/myweb/public_html. Point being, is it possible to separate remote repo path and repo checkout path? If not is it possible to implement this option? Am I making any sense? :)

Doesn't work when using Fish shell

git deploy setup -r dep2
Password:
[dep2] $ cd /tmp/testr3.git && \
  git init  && \
  git config receive.denyCurrentBranch ignore
fish: Expected a command name, got token of type 'Run job in background'. Did you mean 'COMMAND; and COMMAND'? See the help section for the 'and' builtin command by typing 'help and'.
Standard input: cd /tmp/testr3.git && git init  && git config receive.denyCurrentBranch ignore

FILE: [local] hooks/post-receive.sh  ->  [dep2] /tmp/testr3.git/.git/hooks/post-receive
Password:
/usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-scp-1.1.2/lib/net/scp.rb:359:in `block (3 levels) in start_command': SCP did not finish successfully (1) (Net::SCP::Error)
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/channel.rb:590:in `call'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/channel.rb:590:in `do_close'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:580:in `channel_close'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:459:in `dispatch_incoming_packets'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:216:in `preprocess'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:200:in `process'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:164:in `block in loop'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:164:in `loop'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:164:in `loop'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:113:in `close'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/git-deploy-0.6.0/lib/git_deploy/ssh_methods.rb:97:in `block in ssh_connection'
/usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-scp-1.1.2/lib/net/scp.rb:392:in `await_response_state': scp: /tmp/testr3.git/.git/hooks/post-receive: No such file or directory (RuntimeError
)
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-scp-1.1.2/lib/net/scp.rb:363:in `block (3 levels) in start_command'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/channel.rb:311:in `call'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/channel.rb:311:in `process'

        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:217:in `block in preprocess'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:217:in `each'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:217:in `preprocess'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:200:in `process'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:164:in `block in loop'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:164:in `loop'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/session.rb:164:in `loop'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/connection/channel.rb:269:in `wait'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/git-deploy-0.6.0/lib/git_deploy/ssh_methods.rb:91:in `block in scp_upload'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/git-deploy-0.6.0/lib/git_deploy/ssh_methods.rb:91:in `each'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/git-deploy-0.6.0/lib/git_deploy/ssh_methods.rb:91:in `scp_upload'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/git-deploy-0.6.0/lib/git_deploy.rb:52:in `hooks'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:109:in `invoke'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/git-deploy-0.6.0/lib/git_deploy.rb:44:in `setup'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
        from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/git-deploy-0.6.0/bin/git-deploy:3:in `<top (required)>'
        from /usr/local/Cellar/ruby/1.9.3-p327/bin/git-deploy:23:in `load'
        from /usr/local/Cellar/ruby/1.9.3-p327/bin/git-deploy:23:in `<main>'

Looks like scping the hook failed because the git repo failed to be created.

Incompatible gems

I can't use JRUBY, Rails 4 with git-deploy:

[55][chimkan: /Users/chimkan/Core/sources/basic.chimkan.com]$ bundle install
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies....
Bundler could not find compatible versions for gem "thor":
  In Gemfile:
    git-deploy (~> 0.6.1) java depends on
      thor (= 0.14.6) java

    sass-rails (~> 4.0.0) java depends on
     thor (0.18.1)

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    rails (= 4.0.0) java depends on
      railties (= 4.0.0) java

    sass-rails (~> 4.0.0) java depends on
      railties (4.0.0.rc2)

cannot load such file -- thor (LoadError)

Hi guys,

I'm trying to execute the command:

git deploy setup -r "stage"

But I'm getting this error:

/Users/igorescobar/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require': cannot load such file -- thor (LoadError)
    from /Users/igorescobar/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
    from /Users/igorescobar/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
    from /Users/igorescobar/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/git-deploy-0.6.1/lib/git_deploy.rb:1:in `<top (required)>'
    from /Users/igorescobar/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /Users/igorescobar/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /Users/igorescobar/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/git-deploy-0.6.1/bin/git-deploy:2:in `<top (required)>'
    from /Users/igorescobar/.rbenv/versions/2.0.0-p247/bin/git-deploy:23:in `load'
    from /Users/igorescobar/.rbenv/versions/2.0.0-p247/bin/git-deploy:23:in `<main>'

Any ideas?

rollback feature possible?

Would such a feature be possible to add to a git-deploy? It is the only thing missing in this setup that would necessary to have.

bundler install fails on gems from git sources

When I'm updating my Gemlock.file deploy fails on bundle install:

$ git diff HEAD^1
diff --git a/Gemfile.lock b/Gemfile.lock
index c207a64..356afa8 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -8,7 +8,7 @@ GIT

 GIT
   remote: git://github.com/troex/APNS.git
-  revision: e02c653b183e80e5732f308b2e5f26f868f3a8e2
+  revision: 34f92db82ae708b97551484113816df59ab751c8
   specs:
     apns (0.9.0)

$ git push amiget 
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 343 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: HEAD is now at 302631b update APNS gem
remote: files changed: 1
remote: Fetching source index for https://rubygems.org/
remote: fatal: Not a git repository: '.git'
remote: Updating git://github.com/troex/APNS.git
remote: fatal: Not a git repository: '.git'
remote: Git error: command `git fetch --force --quiet --tags 'git://github.com/troex/APNS.git' "refs/heads/*:refs/heads/*"` in directory /var/www/apns.amiget.com/app/vendor/bundle/ruby/1.9.1/cache/bundler/git/APNS-cda91886ee68df538b8678105b9abb9553ec394b has failed.
remote: If this error persists you could try removing the cache directory '/var/www/apns.amiget.com/app/vendor/bundle/ruby/1.9.1/cache/bundler/git/APNS-cda91886ee68df538b8678105b9abb9553ec394b'
To [email protected]:app
   57289b2..302631b  master -> master

$ grep APNS Gemfile
gem 'apns', :git => 'git://github.com/troex/APNS.git'

git-deploy setup fails with port specification in some cases

In certain cases git deploy setup -r "environment" will incorrectly translate the port number in the remote into a directory. Changing the line

url = 'ssh://' + url.sub(%r{:/?}, '/') unless url =~ %r{^[\w-]+://}

to

url = 'ssh://' +url

Solved the problem for a remote in the format of:

[email protected]:12345/apps/appid-staging

Without this change, the remote would be parsed as:

[email protected]/12345/apps/appid-staging

I am sure there was a reason for the url.sub() call, but without knowing what it was, I didn't want to try fixing it through a PR. The line in question is https://github.com/mislav/git-deploy/blob/master/lib/git_deploy/configuration.rb#L51

Feature: Possible to see log when deploying

It would be useful to see the log when deploying instead of it just happening in the background (the restart commands that are run etc) because sometime (if we like it or not) a deploy goes bad.

Compile Rmagic after deploy

Somehow the build of rmagic fails in my setup. But builds just fine when bundled from the commandline by hand.

It might have to do with my setup of bundler and vendored gems (I am kinda new to vendoring), so please just tell me off, if I am talking nonsense :)

What I tried to achieve is to "Deploy multiple rails apps, with multiple gems, rails and versions of both, on one server (ngnix/passenger)".

Before, I would bundle and vendor the gems locally, add them to git, push to production and then run, amongst others, "gem install -i vendor/bundle/ruby/1.8/ rmagick" on the server. Maybe I am just doing it wrong :).

But maybe this can be solved in a generic way, by invoking a "rake deploy" if that rake task exists. That way, developers can include any custom tasks, such as building native extensions, calling other custom rake tasks and so on.

Errors when running bundle on a rack app

I get the following error on deploy. bundler is available in the command line. I have also checked my system gem set and it's available there too. Is there anything I have missed?

==== Sat Apr 6 20:52:10 EDT 2013 ====
files changed: 2
/usr/local/rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [bigdecimal-1.1.0, daemon_controller-1.1.1, fastthread-1.0.7, io-console-0.3, json-1.5.4, minitest-2.5.1, passenger-3.0.19, rack-1.5.2, rake-0.9.2.2, rdoc-3.9.5] (Gem::LoadError)
    from /usr/local/rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
    from /usr/local/rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
    from /usr/local/rvm/gems/ruby-1.9.3-p385@global/bin/bundle:18:in `<main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p385/bin/ruby_noexec_wrapper:14:in `eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p385/bin/ruby_noexec_wrapper:14:in `<main>'

SSH Passwords Show

Is there a way to make the passwords invisible when inputting them upon request?
When I run git deploy it requests my SSH password, however when I type it in it displays it on the terminal which is a slight security issue.

The solution may be a personal terminal config, however I doubt it as this is the only program I've ever installed that does this.

DL is deprecated, please use Fiddle

Got this when running git deploy setup -r "production"

looks like it fails

running on windows 8 in git bash shell mingw32

DL is deprecated, please use Fiddle
c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/transport/packet_s
tream.rb:103:in `block in next_packet': connection closed by remote host (Net::S
SH::Disconnect)
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/trans
port/packet_stream.rb:93:in `loop'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/trans
port/packet_stream.rb:93:in `next_packet'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/trans
port/session.rb:172:in `block in poll_message'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/trans
port/session.rb:167:in `loop'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/trans
port/session.rb:167:in `poll_message'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/trans
port/session.rb:152:in `next_message'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/session.rb:94:in `block in next_message'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/session.rb:93:in `loop'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/session.rb:93:in `next_message'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/methods/publickey.rb:53:in `authenticate_with'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/methods/publickey.rb:20:in `block in authenticate'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/key_manager.rb:111:in `block in each_identity'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/key_manager.rb:103:in `each'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/key_manager.rb:103:in `each_identity'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/methods/publickey.rb:19:in `authenticate'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/session.rb:78:in `block in authenticate'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/session.rb:65:in `each'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh/authe
ntication/session.rb:65:in `authenticate'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.6.8/lib/net/ssh.rb:19
6:in `start'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/git-deploy-0.6.1/lib/git_deploy
/ssh_methods.rb:96:in `ssh_connection'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/git-deploy-0.6.1/lib/git_deploy
/ssh_methods.rb:43:in `ssh_exec'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/git-deploy-0.6.1/lib/git_deploy
/ssh_methods.rb:35:in `run_test'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/git-deploy-0.6.1/lib/git_deploy
.rb:28:in `setup'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.14.6/lib/thor/task.rb:22
:in `run'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.14.6/lib/thor/invocation
.rb:118:in `invoke_task'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.14.6/lib/thor.rb:263:in
`dispatch'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.14.6/lib/thor/base.rb:38
9:in `start'
        from c:/Ruby200/lib/ruby/gems/2.0.0/gems/git-deploy-0.6.1/bin/git-deploy
:3:in `<top (required)>'
        from c:/Ruby200/bin/git-deploy:23:in `load'
        from c:/Ruby200/bin/git-deploy:23:in `<main>'

Forwarding ssh-agent

Is it possible to forward the ssh agent on the git push?

I tried adding :forward_agent => true in the Net::SSH.start call, but it doesn't seem to affect the git push. I'm having access denied when the submodules update get run.

Clear cache during deploy

Decided to make this an issue to allow for discussion as I'm not sure what the side effects would be.

One of the niceties of doing a new checkout with the traditional Capistrano model is that page-cached pages get left behind and regenerated after each deployment.

Could this be accomplished with git-deploy by setting "clean.requireForce" to false in .git/config and running 'git clean' in the post-reset hook?

Honoring .rvmrc

There is probably related to bundler issues.

Why not take into account the popular RVM approach, which lets rvm invoke bundler through .rvmrc script, maybe something along the lines

if File.file? '.rvmrc'
  puts 'Running "rvm rvmrc load"...'
  run "bash -c 'source #{ENV['HOME']}/.rvm/scripts/rvm ; rvm rvmrc load'"
end

Without that, the hook fails because rvm redefines cd and wants to execute untrusted .rvmrc non-interactively.

/path/to/myapp will not be created

"The "/path/to/myapp" is the directory where your code will reside. It doesn't have to exist; it will be created for you during this setup."

No it won't:
chmod: cannot access `/path/to/myapp': No such file or directory
cp: /path/to/myapp: No such file or directory (RuntimeError)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.