Combine fortrabbit with Bitbucket
Learn how to integrate the second most popular Git-as-a-service provider with your fortrabbit workflow.
Bitbucket is a Git hosting service that offers advanced Git work-flows, such as 'pull requests'. It offers private repos in a free plan and is a popular choice in combination with fortrabbit. It also offers paid plans for "growing teams". Bitbucket is similar to GitHub, please hop over to the GitHub integration article to learn about available work-flows, like having two remotes.
Deployment pipeline
Bitbucket has pipelines to handle hooks to build stuff. In order for Bitbucket to push to your fortrabbit App, you have to create an SSH key pair with Bitbucket and then add the public key to your fortrabbit App.
You will also need to 'fetch' the public key from the fortrabbit deploy service. Do that with the Bitbucket dashboard under repository settings > SSH keys > Known hosts. Add deploy.{region}.frbit.com
.
Example pipeline
The easiest way to deploy to fortrabbit from Bitbucket is to git push
directly to our deploy service in your pipeline, add this to your bitbucket-pipelines.yml
:
pipelines:
branches:
main:
- step:
name: Deploy to STAGING
deployment: staging
script:
- git push --force {staging-app-name}@deploy.{region}.frbit.com:{staging-app-name}.git HEAD:main
- step:
name: Deploy to PRODUCTION
deployment: production
trigger: manual
script:
- git push --force {production-app-name}@deploy.{region}.frbit.com:{production-app-name}.git HEAD:main
Note: This simple workflow does not work if you are building assets in your pipeline that end up adding or changing files that you want to deploy. For that you will need to do a git commit
in your pipeline and that is out of scope for this simple guide.
For more information about how you can manage multiple environments like staging and production on our platform see our multi staging article.