Using Private Bitbucket Repositories With PhoneGap Build

The PhoneGap Build service has been able to associate an application account with a private Github repository for some time now.

As Github charges for private repositories, moving from a free account to a micro account, it's not always easy (or financially viable) to keep your source code private through their system. This is where Bitbucket excels, with unlimited private repositories for any of your projects you wish to remain secret - after all, you don't want everyone to see the code for your next killer app, right?

However, the PhoneGap Build service currently only caters for easily linking your Github private repositories, so how can you still use your private Bitbucket repo and pass it through to the PhoneGap Build service to generate your mobile applications?

It turns out this is incredibly easy. Firstly you will need (obviously) a private Bitbucket repository with code ready to deploy to the build service:

Private Bitbucket repository

Next, when creating your new application in PhoneGap Build, choose the private tab - the open-source tab will only accept Github URLs:

PhoneGap Build Private Repository

Entering in the Bitbucket repo URL 'as it is' won't work. The build service won't be able to access it. So, to use private Bitbucket repositories, simply alter the URL to pass through your repository account password, as you would when sending a basic http authentication request, like so:


The build service will then be able to authenticate against your private Git repository and pull your code in. Nice and easy.

Private PhoneGap Build App

By doing this, you can host your PhoneGap applications in a private repository outside of Github and still access them through the PGBuild services, keeping your source code secure and hidden.

You can also streamline the workflow and deployment process to PhoneGap Build by using the autobuild service I created. Setting up a POST service in Bitbucket will send a request to PhoneGap Build after every successful commit to the repository, which will then trigger an automatic pull request to update the code and compile the application for you, incrementing the build. One commit, numerous processes handled for you. Find out how easy it is to set up an autobuild request on the official site:

comments powered by Disqus