Last updated Oct 9, 2024

Building Bitbucket Data Center from Source Code

This guide describes building a Bitbucket Data Center distribution from the source code. Bitbucket Data Center source code is available to all commercial license holders.

Starting from Bitbucket 8.9.14, 8.19.3 and 9.0.0, you can no longer build the Bitbucket Data Center source code. The source code now acts as a supplement to the Bitbucket Server and Data Center binary distributions.

Consider building a plugin instead!

If you are downloading the source with the intent of customizing Bitbucket Data Center, you should first consider writing a plugin instead. Bitbucket Data Center provides a comprehensive Plugin SDK and a rich set of stable Java APIs for extending its functionality, which are backwards compatible between major releases. If you choose to modify and build the source code yourself, upgrading to newer Bitbucket Data Center versions may be problematic.

If you're really sure you want to modify Bitbucket Data Center's source instead of building a plugin, here are the steps for building Bitbucket Data Center from source:

Download Java and the Bitbucket Data Center source

Bitbucket Data Center 8.0 and later is not compatible with Windows. You must build and run Bitbucket on Linux or Mac OS.

  1. Download and install the Java Development Kit.
    Bitbucket Data Center requires the JDK 1.8 Update 45 release or higher.

  2. Download and extract the Bitbucket Data Center source distribution
    Use your my.atlassian.com account to login (or contact Atlassian's sales department if you don't see the link to download the distribution).

Download the database drivers

Bitbucket Data Center is built using Maven, which is bundled with the source distribution. During the build, Maven will download the dependencies of Bitbucket Data Center and store them locally. Two of those dependencies are Oracle's and Microsoft's database drivers, which need to be manually installed for legal reasons. If you do not have those drivers in your local Maven repository, follow these instructions to install them:

  1. Download the Oracle JDBC driver (you might need to sign up for an Oracle account), - in the Oracle Database 12c Release 2 (12.2.0.1) JDBC Drivers section, find and download the ojdbc8.jar driver, - copy the driver in the directory where you extracted the source distribution;

  2. And, in the same directory (containing the source distribution of Bitbucket Data Center), run the following command:

    1
    2
    ./mvn3.sh install:install-file -DgroupId=com.oracle.jdbc -DartifactId=ojdbc8 -Dversion=12.2.0.1-atlassian-hosted -Dpackaging=jar -Dfile=ojdbc8.jar -Dmaven.repo.local="`pwd`/localrepo"
    
  3. Next, download the Microsoft JDBC driver:

    1
    2
    * find and download the _sqljdbc\_4.0.2206.100\_enu.tar.gz_ driver,
    * extract the archive to a temporary directory (such as `/tmp/ms-driver`),
    * and, in the directory containing the source distribution of Bitbucket Data Center, run the following commands
      (after replacing the path of the driver's directory by the correct one on the first line):
    
    1
    2
    export MS_DRIVER_PATH="/tmp/ms-driver"
    ./mvn3.sh install:install-file -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc -Dversion=4.0.2206 -Dpackaging=jar -Dfile=$MS_DRIVER_PATH/enu/sqljdbc.jar -Dmaven.repo.local="`pwd`/localrepo"
    ./mvn3.sh install:install-file -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc_auth -Dversion=4.0.2206 -Dclassifier=x64 -Dpackaging=dll -Dtype=dll -Dfile=$MS_DRIVER_PATH/enu/auth/x64/sqljdbc_auth.dll -Dmaven.repo.local="`pwd`/localrepo"
    ./mvn3.sh install:install-file -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc_auth -Dversion=4.0.2206 -Dclassifier=x86 -Dpackaging=dll -Dtype=dll -Dfile=$MS_DRIVER_PATH/enu/auth/x86/sqljdbc_auth.dll -Dmaven.repo.local="`pwd`/localrepo"
    

Build Bitbucket Data Center from source

  1. Run the following command in the directory containing the source distribution of Bitbucket Data Center:

    1
    2
    ./build.sh
    

    This will perform a full build of Bitbucket Data Center. The distribution ZIP will be created in the subdirectory bitbucket-parent/distribution/default/target.

  2. Then, to develop Bitbucket Data Center in your IDE: - create a new project from the bitbucket-parent/pom.xml file in the directory of the source distribution, - enable the Tomcat integration in your IDE, - once the project is set up, deploy the Bitbucket Data Center WAR file using the Tomcat integration.

  3. Alternatively, from the command line: - in the directory containing the source distribution (after running build.sh in step 1), run:

    1
    2
    cd bitbucket-parent/webapp/default
    mvn cargo:run
    
    1
    2
    - then, after each change, re-run `build.sh`.
    

Rate this page: