Git deployment with Dandelion
Git is the bee’s knees when it comes to version control and definitely my DCVS of choice. It’s an indispensable tool for collaborating with other developers and has become such an integral part of my development workflow that I cannot imagine working nearly as effectively without it.
When it comes time for deployment, there are a handful of fantastic options including Capistrano or even just Git itself, however, these require shell access to the server- something that is usually not available in shared hosting environments. One is left either transferring the entire codebase to the server on every deployment (very time consuming) or manually keeping track of which files have changed since the last time we deployed (error prone).
Dandelion takes the second approach but manages revisions for you so there’s no need to manually track changed files- Git does this anyway and Dandelion leverages that. Dandelion keeps track of the currently deployed revision so that it may later be used to generate a list of files that have been changed, added or deleted and transfer those files via FTP or SFTP.
Getting Started
Dandelion is written in Ruby and requires that both Ruby and RubyGems be installed (note that Ruby 1.9 now includes RubyGems by default). Rather than using your operating system’s packaging system, I highly recommend using RVM for installing and managing Ruby versions and gems.
Assuming Ruby is ready to go, install Dandelion…
$ gem install dandelion
In the root of the Git repository you wish to deploy, create a file called dandelion.yml in which to specify configuration options.
scheme: sftp
host: example.com
username: user
password: pass
path: path/to/deployment
exclude:
- .gitignore
- dandelion.yml
Then start deploying.
$ dandelion deploy
This will transfer all files in the HEAD revision of your repository to the location specified in dandelion.yml. Next time you deploy, Dandelion will know which files have changed saving you time and headache.
For more information or to contribute to Dandelion head over to http://github.com/scttnlsn/dandelion.









Comments
May 17, 2011 at 2:58 pm
Thanks for the great work put into this little gem! It has proven very useful and efficient…
December 19, 2011 at 1:22 pm
Thank you for sharing this! I wish I would have found it sooner! So useful!
i have a question, if I may. Is there is any way to make Dandelion aware of the remote revision before the first deployment? I ask this in hopes that I can avoid having to let Dandelion re-upload the entire set of files on the first deployment.
December 19, 2011 at 2:09 pm
Glad you’re finding it useful. You could create a file called “.revision” (in the root of your remote path) that contains the commit SHA of the remote revision. Dandelion looks for this file when determining which files need to be transfered.
It might be nice in future versions of Dandelion to allow this do be done through a command.
December 19, 2011 at 5:46 pm
Ah, that makes perfect sense. I had assumed Dandelion stored that info locally. Such a great tool. Thanks again!
January 7, 2012 at 2:26 pm
For some reason I’m having issues with dandelion uploading images: http://pastie.org/3144668.
It doesn’t seem to be all images either – but there’s no discernable difference between the ones that fail and the ones that are deployed.
Any thoughts for why that might be?
Thanks a lot!!
January 8, 2012 at 7:28 pm
Thanks for reporting this- I’ll take a look at it.
January 9, 2012 at 11:43 am
Steve, are you able to test this out on Ruby 1.9?
March 17, 2012 at 6:17 pm
Is there a way to add multiple host to the dandelion.yml file? I have 2 servers that I need to deploy to.
This would allow us to say
dandelion deploy -host server1
or
dandelion deploy -host server2
April 7, 2012 at 11:42 am
The only way to achieve that currently is to maintain two separate configuration files and then run:
dandelion –config=server1.yml deploy
dandelion –config=server2.yml deploy
April 7, 2012 at 11:23 am
This is great! Thank you.
May 17, 2012 at 1:29 pm
Can I exclude directories in the .yml file? how do I go about doing that?
May 17, 2012 at 1:46 pm
Dandelion will skip all excluded files that begin with the strings listed in your .yml file. For example, if you’d like to exclude all files in directory “foo/bar” add “foo/bar” (or “foo/bar/”) to your exclude list. If this is not working as expected please open an issue on GitHub: https://github.com/scttnlsn/dandelion/issues
Thanks!