If you want to integrate DeepCode with your self-managed Bitbucket Server, request a DeepCode Server!

To learn more about the DeepCode Server and the prerequisites, go here.  

We support Bitbucket Server 5.14 or greater. However, versions below may also work.

Video Tutorial


Creating an application link

In order to register the DeepCode integration with Bitbucket Server you need to create an "application link".

  1. In a shell, generate a public/private key pair and keep the output files deepcode.pem and deepcode.pub 
openssl genrsa -out deepcode.pem 2048; openssl rsa -in deepcode.pem -pubout -out deepcode.pub
  1. Log into Bitbucket Server as administrator.
  2. Go to settings.
  3. Click on “Application Links”.
  4. Enter “http://deepcode.deepcode”.
  5. Click “Create new link”. If a popup tells you that no response could be received from the URL, click “Continue”.
  6. As Application Name, enter “deepcode”.
  7. Make sure that the “Application Type” is set to “Generic Application”.
  8. Click “Continue”.
  9. Now click on the pencil on the just created deepcode application link.
  10. Click on “Incoming Authentication”. As Consumer key, enter “deepcode”. As Consumer name, enter “deepcode”. As Description, enter “deepcode”. As public key, enter the public key that you created earlier (cat deepcode.pub).
  11. Click “Save”.


Creating a user account

DeepCode needs to have access to one user account as which it will create comments on your pull requests and commits. It is recommended to choose a name for the user that signals that this user is controlled artificially (e.g. "DeepCode Bot"). The user can either be created as normal user or as admin user. The latter is easier to setup but you might feel more comfortable not assigning admin rights. In either case you need to record the username and the password for a later step in the setup.


1. Normal user

Create a normal user. DeepCode's code review will work for all repositories for which the user has "Read" permissions. Thus you need to manually give it these permissions on all repositories for which you want to enable the code review.


2. Admin user

Create an admin user. DeepCode's code review will work for all current and future repositories.



Configuring DeepCode Server

DeepCode Server is the self-managed software that will integrate with Bitbucket Server. Before you set it up, first create the configuration files that are necessary to run DeepCode Server:

  1. Create a directory at some path that will hold all configuration files. We will refer to this path as CONFIG_DIR.  
  2. Move the filedeepcode.pem that you created earlier into CONFIG_DIR (CONFIG_DIR/deepcode.pem). 
  3. Create a file CONFIG_DIR/bb.env  with the following content:

FRONT_PORT=any port available on your host, 8080 by default


Insert the URL under which DeepCode Server will be reachable. E.g. https://deep.code or Please note that because the server is running inside a docker container the hostname localhost will not work.


Insert the URL of your Bitbucket Server. E.g. https://bit.bucket or http://17.65.954.21:7990


Insert the consumer key you specified in Application Link. If you followed default recommendations, leave deepcode.


Insert the username and password of the service account that you created earlier.


If you host GitLab using self-signed SSL certificate, please set this value or 0 (number zero) Otherwise, remove it or leave it 1 


The container exposes a webserver on port 8080 by default. Usually you would bind it to port 80 by replacingFRONT_PORT with 80. 



Command for starting the server

The full command to start DeepCode Server is as follows:

  docker run --rm -it -v '/var/run/docker.sock:/var/run/docker.sock' -v $PWD:$PWD -w $PWD --env-file ./bb.env --env "BIT_BUCKET_SERVER_OAUTH_PRIVATE_KEY=$(cat deepcode.pem)" --env --name deepcode deepcode

Arguments description:

docker run                   \ # Run a docker container
    --rm                     \ # Remove the container after it was stopped.
    -it                      \ # (Optional) to acquire terminal
    -v '/var/run/docker.sock:/var/run/docker.sock' \ # Mount Docker socket file
    -v $PWD:$PWD             \ # Mount working dir for storing container data between restarts
    -w $PWD                  \ # set working directory
    --env-file ./bb.env      \ # Configuration file created earlier
    --env "BIT_BUCKET_SERVER_OAUTH_PRIVATE_KEY=$(cat deepcode.pem)" \ # Private key required for authentication
    --name deepcode          \ # (Optional) set container name
    deepcode                   # Name of docker image to run.

Container data

This folder will contain data of the running container:

  • mysqldata  for persistent database
  • redisdata   for cache
  • clones  for temporary cache with cloned repositories




DeepCode Server does not receive webhooks from Bitbucket

Once code review is enabled on a repository, a webhook should appear in "Repository settings - Webhooks". In case there is an error with the webhook, please restart Bitbucket server.

To finish the integration, manage the DeepCode Server

If you encounter problems at any point during the setup please don't hesitate to ask for help at deepcode@deepcode.ai