Connect BitBucket Pipelines to FortRabbit

  1. Generate SSH key in BitBucket.
  2. Add the SSH key to the FortRabbit server via terminal.
    1. ssh your-account@deploy.us1.frbit.co
    2. cd ~/.ssh
    3. vi authorized_keys
    4. Paste the BitBucket SSH key.
    5. Press escape, then type : and wq to write and quit.
  3. In BitBucket, add the deploy.us1.frbit.com FortRabbit url found in SFTP tab as a known host. The fingerprint should be generated automatically.
  4. Create a bitbucket-pipelines.yml file in your project root. The code below is a good starting template.

image: php:7.0.0
pipelines:
branches:
your-project-name:
- step:
deployment: staging
script:
- apt-get update && apt-get install -y unzip git ssh
- git remote add fortrabbit your-project-name@deploy.us1.frbit.com:your-project-name.git
- git push fortrabbit your-project-name -f

  1. Note that your-project name should also match one of your branch names. This branch will be used to deploy. Other branches will still push to BitBucket but won’t be uploaded onto FortRabbit.

Git: Get All Branches (even new remotes)

tldr;

git fetch --all (or git remote update)
git pull --all

Important for projects with multiple remotes:
git checkout -t origin/branch-name

This last piece will prevent a detached-head situation when adding branches that currently only exist on remote.


https://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches

https://stackoverflow.com/questions/1783405/how-do-i-check-out-a-remote-git-branch


💩

Bitbucket + FortRabbit (or how to Git with multiple remotes)

Say you are using FortRabbit, which runs its own Git repository just for deployment purposes. You want commit history and user control, so you want something else like BitBucket as your primary repository.

You can have both (wow).

Step 1: Create a new repository in BitBucket. Do NOT create a readme file. There has to be no commit history or you will receive errors from FortRabbit.

Step 2: Clone your FortRabbit repository into a new folder on your computer. Let’s use double-repo for this example.

Step 3: Follow the steps below to remove FortRabbit as double-repo‘s remote and add BitBucket. Then push all the files to BitBucket.
https://www.atlassian.com/git/tutorials/git-move-repository

Step 4: Add FortRabbit as a remote using the syntax below. This will provide a unique name for the remote (fortrabbit) rather than the default, origin:
https://help.fortrabbit.com/github

Now the repositories have shared histories. It’s important that both repositories were synched when they were new to avoid history conflicts (which are more difficult when the repositories are managed without controls, by FortRabbit for example).

Now you can:

  • Push to BitBucket with git push origin master.
  • Push to FortRabbit with git push fortrabbit master.
  • Add new contributers to BitBucket without allowing them deployment privileges.

💩