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.
Creating an application link
In order to register the DeepCode integration with Bitbucket Server you need to create an "application link".
- In a shell, generate a public/private key pair and keep the output files
openssl genrsa -out deepcode.pem 2048; openssl rsa -in deepcode.pem -pubout -out deepcode.pub
- Log into Bitbucket Server as administrator.
- Go to settings.
- Click on “Application Links”.
- Enter “http://deepcode.deepcode”.
- Click “Create new link”. If a popup tells you that no response could be received from the URL, click “Continue”.
- As Application Name, enter “deepcode”.
- Make sure that the “Application Type” is set to “Generic Application”.
- Click “Continue”.
- Now click on the pencil on the just created deepcode application link.
- 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).
- 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:
- Create a directory at some path that will hold all configuration files. We will refer to this path as
- Move the file
deepcode.pemthat you created earlier into
- Create a file CONFIG_DIR/bb.env with the following content:
PRODUCT=bb_op HOST_URL=https://my-deepcode-url FRONT_PORT=any port available on your host, 8080 by default BIT_BUCKET_SERVER_URL=https://my-bitbucket-url BIT_BUCKET_SERVER_OAUTH_CONSUMER_KEY=deepcode BIT_BUCKET_SERVER_USER_NAME=my-user BIT_BUCKET_SERVER_PASSWORD=my-super-secure-password NODE_TLS_REJECT_UNAUTHORIZED=0 or 1
Insert the URL under which DeepCode Server will be reachable. E.g.
http://18.104.22.168:8081. Please note that because the server is running inside a docker container the hostname localhost will not work.
Insert the consumer key you specified in Application Link. If you followed default recommendations, leave
USERNAME and PASSWORD
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
The container exposes a webserver on port 8080 by default. Usually you would bind it to port 80 by replacing
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
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.
This folder will contain data of the running container:
mysqldatafor persistent database
clonesfor 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 email@example.com