Alternate Capistrano Usernames // writing
At bezurk I’m using my own laptop to create great masterpieces of HTML (ahem), but as such my Macbook isn’t configured quite the same as everyone else’s.
Like good developers we’re now using Capistrano 2 to deploy the products on the site. If you’re not using it you should be, it has it’s history in the Rails community but we use it for deploying all our sites.
The only issue is the username and email I’ve been given on the bezurk ‘estate’ doesn’t match the one on my Macbook. Hence the standard Capistrano assumption, that the username on the server and the SVN repository are the same, wasn’t working.
I stumbled accross this guide to Cap passwords and made the following addition to our capfile.
set :user, ENV['BEZ_USER'] || ENV['USER']
set :scm_user, ENV['BEZ_USER'] || ENV['USER']
This sets the user and the version control user to be the BEZ_USER environment variable or the standard USER variable (same as the default behaviour). This doesn’t break for everyone else – whose username is the same as the one on the SVN and production server.
However in my case there is a difference thus I added the following to the bottom of my ~/.bash_profile (which runs every time you start a new terminal window)
export BEZ_USER=svn_username_here
Hence from now on I can just forget it, it’s set every time I go to the terminal and hasn’t broken the existing convention for anyone else! You could even extend the approach to different SVN repositories as long as you use a differently named environment variable.