Garry Dolley wrote a git module for Capistrano, but it is included in version 2.1 so you don't need to do anything special to use it. In your gem directory it's at capistrano-2.2.0/lib/capistrano/recipes/deploy/scm/git.rb, and I'd suggest reading the doc header because it has some nice ways to play with variables that take advantage of the distributed nature of git.
- Set the scm type and replace your repository variable with the URI of your git repository:
- set :scm, :git
- set :repository, "username@server.domain.name:/path/to/repo/myproj.git"
- set :deploy_via, :remote_cache
- If you are using git 1.5.3 or higher on all your machines, you can use submodules by
- set :git_enable_submodules, true
- Set the branch to deploy from:
- set :branch, "master"
If you are using multi stage deployment you can put the "set :branch, 'master'" in the stage files and could even point each stage at a different branch that you merge to when the code is ready.
You can use the normal scm_user/scm_password options and capistrano will handle the authentication via ssh. Another option is setting up password-less public keys on the target servers with a restricted shell on the git server. Git will give you trouble if your HTTP repository is authenticated (needs ~/.netrc) or has an SSL certificate that doesn't validate (doesn't work if the CN differs from the dns name) so I didn't go that route.
Remove any :checkout, or other :deploy_via variables you have in your deploy.rb file and you're set.
No comments:
Post a Comment