Configure an agent with Bitbucket Data Center access
In order to view recipe results and commit changes from a recipe back to Bitbucket, you'll need to create an application link in Bitbucket and configure the Moderne agent with the appropriate variables.
This guide will walk you through everything you need to know to get started with this.
Prerequisites
- You will need administrator access to your Bitbucket on-premise instance
Step 1: Create an OAuth connection
-
Go to the Administration page in your Bitbucket instance
-
Select Application Links from the System section
-
Click on "Create link"
-
Ensure that the Application Type is set to External application
-
Ensure that the Direction is set to Incoming
-
Click Continue
-
Define a new Incoming Application with the following settings:
Field Value Name ModerneRedirect URL https://your-domain.moderne.ioApplication Permissions Repositories - Read
Repositories - Write -
Click Save to complete the Application Link creation
-
Copy the "Client ID" and "Client Secret" to use in the next step
OAuth1.0a (deprecated)
Generate a public and private key for Bitbucket
This key will be used by the Moderne agent to talk to Bitbucket.
openssl genrsa -out bitbucket_privatekey.pem 1024
openssl req -newkey rsa:1024 -x509 -key bitbucket_privatekey.pem -out bitbucket_publickey.cer -days 365
openssl pkcs8 -topk8 -nocrypt -in bitbucket_privatekey.pem -out bitbucket_privatekey.pcks8
openssl x509 -pubkey -noout -in bitbucket_publickey.cer > bitbucket_publickey.pem
Create an Application Link in Bitbucket
-
Go to the Administration page in your Bitbucket instance
-
Select Application Links from the System section
-
Click on "Create link"
-
Ensure that the Application Type is set to Atlassian product (this looks weird, but this is the documented path for external applications to integrate)
-
Enter the URL for your Moderne instances as the Application URL:

Create link -
Click Continue
-
Define a new Incoming Application with the following settings:
Field Value Application Name ModerneApplication Type Generic Application Service Provider Name moderneConsumer key OauthKeyRequest token URL https://your-domain.moderne.ioAccess token URL https://your-domain.moderne.ioAuthorize URL https://your-domain.moderne.ioCreate incoming link ✅ -
Click Continue
-
Complete the Incoming Link configuration:
Field Value Consumer Key OauthKeyConsumer Name ModernePublic Key Paste the public key ( bitbucket_publickey.pem) from step 1 -
Click Continue to complete the Application Link creation
Step 2: Configure the Moderne agent
In order for the Moderne agent to work with your Bitbucket instance, you'll need to provide it with the information you generated in Step 1.
You can configure multiple Bitbucket instances by including multiple entries, each with a different {index}.
To enable OAuth2 support, set MODERNE_AGENT_BITBUCKET_{index}_OAUTH_KEY to your Client ID and MODERNE_AGENT_BITBUCKET_{index}_OAUTH_SECRET to your Client Secret from Step 1.
OAuth1.0a (deprecated)
Configure the Bitbucket private key for the Moderne agent
For OAuth1.0a, you'll need to convert the private key you generated in Step 1 (OAuth1.0a section) to a single-line string.
If you're using Bash or another shell, copy the output of the following command and set it as MODERNE_AGENT_BITBUCKET_{index}_PRIVATEKEY:
cat bitbucket_privatekey.pcks8 | sed '1d;$d' | tr -d '\n'
If you're not using a shell, please follow these instructions instead:
- Open the
bitbucket_privatekey.pcks8file in a text editor - Remove the first and last line (header and footer) of the private key
- The first line should be:
-----BEGIN PRIVATE KEY----- - The last line should be:
-----END PRIVATE KEY-----
- The first line should be:
- Remove all newline and return characters
- Copy the contents as a single-line string and use it for
MODERNE_AGENT_BITBUCKET_{index}_PRIVATEKEY
Moderne Agent Bitbucket properties
The following table contains all of the variables/arguments you need to add to your Moderne agent run command in order for it to work with your Bitbucket instance. Please note that these variables/arguments must be combined with ones found in other steps in the Configuring the Moderne agent guide.
- OCI Container
- Executable JAR
Environment variables:
| Variable Name | Required | Default | Description |
|---|---|---|---|
MODERNE_AGENT_BITBUCKET_{index}_URL | true | The fully-qualified URL of the running Bitbucket instance. For example: https://bitbucket.myorg.com. | |
MODERNE_AGENT_BITBUCKET_{index}_PRIVATEKEY | conditional | (OAuth1.0a only) The private key you configured for this Bitbucket instance. | |
MODERNE_AGENT_BITBUCKET_{index}_OAUTH_KEY | conditional | (OAuth2 only) The client id for the Application Link that you configured for this Bitbucket instance. | |
MODERNE_AGENT_BITBUCKET_{index}_OAUTH_SECRET | conditional | (OAuth2 only) The client secret for the Application Link that you configured for this Bitbucket instance. | |
MODERNE_AGENT_BITBUCKET_{index}_ALTERNATEURLS_{index} | false | The list of alternative fully-qualified URL of the running Bitbucket instance. For example: https://bitbucket.myorg.com. | |
MODERNE_AGENT_BITBUCKET_{index}_SKIPSSL | false | false | Specifies whether or not to skip SSL validation for HTTP connections to this Bitbucket instance. This must be set to true if you use a self-signed SSL/TLS certificate. |
MODERNE_AGENT_BITBUCKET_{index}_SSH_PRIVATEKEY | false | The SSH private key used to establish a SSH connection with Bitbucket. | |
MODERNE_AGENT_BITBUCKET_{index}_SSH_PASSPHRASE | true (If the SSH private key is specified) | The passphrase used to encrypt the SSH private key. This is required if the private key is specified and encrypted. | |
MODERNE_AGENT_BITBUCKET_{index}_SSH_SSHFILENAME | true (If the SSH private key is specified) | The file name of the private key, which the agent will store locally. | |
MODERNE_AGENT_BITBUCKET_{index}_SSH_USER | true (If the SSH private key is specified) | The username used for SSH communication with Bitbucket. | |
MODERNE_AGENT_BITBUCKET_{index}_SSH_PORT | true (If the SSH private key is specified) | 7999 | The port used to communicate via SSH with Bitbucket. |
Example:
docker run \
# ... Existing variables
-e MODERNE_AGENT_BITBUCKET_0_OAUTH_KEY=yourClientId \
-e MODERNE_AGENT_BITBUCKET_0_OAUTH_SECRET=yourClientSecret \
-e MODERNE_AGENT_BITBUCKET_0_URL=https://bitbucket.myorg.com \
# ... Additional variables
Arguments:
| Argument Name | Required | Default | Description |
|---|---|---|---|
--moderne.agent.bitbucket[{index}].url | true | The fully-qualified URL of the running Bitbucket instance. For example: https://bitbucket.myorg.com. | |
--moderne.agent.bitbucket[{index}].privateKey | conditional | (OAuth1.0a only) The private key you configured for this Bitbucket. | |
--moderne.agent.bitbucket[{index}].oauth.key | conditional | (OAuth2 only) The client id for the Application Link that you configured for this Bitbucket instance. | |
--moderne.agent.bitbucket[{index}].oauth.secret | conditional | (OAuth2 only) The client secret for the Application Link that you configured for this Bitbucket instance. | |
--moderne.agent.bitbucket[{index}].alternateUrls[{index}] | false | The list of alternative fully-qualified URL of the running Bitbucket instance. For example: https://bitbucket.myorg.com. | |
--moderne.agent.bitbucket[{index}].skipSsl | false | false | Specifies whether or not to skip SSL validation for HTTP connections to this Bitbucket instance. This must be set to true if you use a self-signed SSL/TLS certificate. |
--moderne.agent.bitbucket[{index}].ssh.privateKey | false | The SSH private key used to establish a SSH connection with Bitbucket. | |
--moderne.agent.bitbucket[{index}].ssh.passphrase | true (If the SSH private key is specified) | The file name of the private key, which the agent will store locally. | |
--moderne.agent.bitbucket[{index}].ssh.sshFileName | true (If the SSH private key is specified) | The file name of the private key, which the agent will store locally. | |
--moderne.agent.bitbucket[{index}].ssh.user | true (If the SSH private key is specified) | The username used for SSH communication with Bitbucket. | |
--moderne.agent.bitbucket[{index}].ssh.port | true (If the SSH private key is specified) | 7999 | The port used to communicate via SSH with Bitbucket. |
Example:
java -jar moderne-agent-{version}.jar \
# ... Existing arguments
--moderne.agent.bitbucket[0].oauth.key=yourClientId \
--moderne.agent.bitbucket[0].oauth.secret=yourClientSecret \
--moderne.agent.bitbucket[0].url=https://bitbucket.myorg.com \
# ... Additional arguments