Configure an agent with Bitbucket Data Center access
Configuring your Moderne Agent instance with Bitbucket is a prerequisite for both viewing recipe results within the Moderne application and committing changes from a recipe.
This guide will walk you through configuring a new Application Link within your Bitbucket Server or Bitbucket Data Center instance.
- Administrator access to your BitBucket on-premise instance.
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
- 1.Go to the Administration page of Bitbucket
- 2.Select Application Links from the System section
- 3.Click on "Create link"
- 4.Ensure that the Application Type is set to Atlassian product (this looks weird, but this is the documented path for external applications to integrate)
- 5.Enter the the URL for your Moderne instances as the Application URL
- 6.Click Continue
- 7.Define a new Incoming Application with the following settings:FieldValueApplication Name
Moderne
Application TypeGeneric ApplicationService Provider Namemoderne
Consumer keyOauthKey
Request token URLhttps://your-domain.moderne.io
Access token URLhttps://your-domain.moderne.io
Authorize URLhttps://your-domain.moderne.io
Create incoming link✅ - 8.Click Continue
- 9.Complete the Incoming Link configurationFieldValueConsumer Key
OauthKey
Consumer NameModerne
Public KeyPaste the public key (bitbucket_publickey.pem
) from step 1 - 10.Click Continue to complete the Application Link creation
To complete the set-up of Bitbucket with the agent we will need to define the private key,
bitbucket_privatekey.pcks8
, we generated in Step 1 as a run-time parameter for the agent.- 1.Open up
bitbucket_privatekey.pcks8
in a text editor. - 2.Remove the first and last line (header and footer) of the private key.
- 1.First and last lines would be:
-----BEGIN PRIVATE KEY-----
and-----END PRIVATE KEY-----
- 3.Remove all newline and return characters and copy the contents of the file as a single-line string.
- 4.Depending on how you run your Agent, you will define the run-time variables
moderne.agent.bitbucket[0].private-key
with the single-line private key.
Using Bash or other shells?
Quickly get a single-line instance of your private key with the key header/footer removed
cat bitbucket_privatekey.pcks8 | sed '1d;$d' | tr -d '\n'
Please note that the commands and options below omit standard options documented at Standard configuration. You will need to merge the standard options into the commands documented below, which is indicated via ellipses.
OCI Container
Executable JAR
You can configure multiple bitbuckets by including multiple entries with different indices. The private key of each index must match up with the host for that index.
MODERNE_AGENT_BITBUCKET_{index}_PRIVATEKEY
- Private key configured in previous stepMODERNE_AGENT_BITBUCKET_{index}_URL
- fully-qualified URL of running bitbucket instance. example:https://bitbucket.myorg.com
MODERNE_AGENT_BITBUCKET_{index}_SKIPSSL
- skip SSL validation for HTTP connections to this Bitbucket instance (defaults to false)
Example using Docker (note that host and private-key are fake):
docker run \
...
-e MODERNE_AGENT_BITBUCKET_0_PRIVATEKEY=ABCDE \
-e MODERNE_AGENT_BITBUCKET_0_URL=https://bitbucket.myorg.com \
-e MODERNE_AGENT_BITBUCKET_1_PRIVATEKEY=FGHIJ \
-e MODERNE_AGENT_BITBUCKET_1_URL=http://bitbucket2.myorg.com \
...
You can configure multiple bitbuckets by including multiple entries with different indices. The private key of each index must match up with the host for that index.
moderne.agent.bitbucket[{index}].private-key
- Private key configured in previous stepmoderne.agent.bitbucket[{index}].url
- fully-qualified URL of running bucketbucket instance. example:https://bitbucket.org
moderne.agent.bitbucket[{index}].skipSsl
- skip SSL validation for HTTP connections to this Bitbucket instance (defaults to false)
Note: system properties can be used in place of arguments. As an example, use
-Dmoderne.agent.token={token_value}
as an argument instead of --moderne.agent.token={token_value}
as an argument.Example (note that host and private-key are fake):
java -jar moderne-agent-{version}.jar \
...
--moderne.agent.bitbucket[0].private-key=ABCDE \
--moderne.agent.bitbucket[0].url=https://bitbucket.myorg.com \
--moderne.agent.bitbucket[1].private-key=FGHIJ \
--moderne.agent.bitbucket[1].url=http://bitbucket2.myorg.com \
...
Last modified 25d ago