Skip to content

Instantly share code, notes, and snippets.

@stevegrunwell
Created August 20, 2013 19:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stevegrunwell/6286357 to your computer and use it in GitHub Desktop.
Save stevegrunwell/6286357 to your computer and use it in GitHub Desktop.
Easily add a new Bitbucket repo on a Redmine server. Add this to the Redmine user's .bash_profile, run `bitbucket-add-repository <slug>`, then add the repo to Redmine project configuration. Modifying this to use with Github is trivial, just update git@bitbucket.org to git@github.com (and update textual references, of course).
# Create a bare clone in ~/git_repositories/{slug}.git
# Before running this command ensure that the repo on Bitbucket has an appropriate deploy key.
# You'll also want to set a POST hook (e.g. http://{redmine}/github_hook?project_id={slug})
#
# Usage: bitbucket-add-repository <slug>
function bitbucket-add-repository {
base=/home/redmine/git_repositories/
if [ -n "$1" ]; then
path=$base$1.git
git clone --bare git@bitbucket.org:buckii/$1.git $path
echo -e "\nWhen prompted by Redmine provide the following path:\n$path\n"
else
echo "You must specify a Bitbucket repo name (minus the .git extension) to clone"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment