Bitbucket module

Edition

Incubator (services)

Issues

Git

Git

Latest

1.0

Compatible with Magnolia 6.2.

The Bitbucket module allows you to sync files to a Bitbucket repository.

It leverages a Magnolia REST client that can be configured using either JCR (Magnolia 6.1) or YAML (Magnolia 6.2). Both REST clients function equally.

The module adds an action to the resources workspace that allows you to export nodes to Bitbucket.

This module is at the INCUBATOR level.

Installing with Maven

Maven is the easiest way to install the module. Add the following to your bundle:

<dependency>
  <groupId>info.magnolia.module.bitbucket</groupId>
  <artifactId>bitbucket-resources</artifactId>
  <version>1.0</version>
</dependency>

<dependency>
  <groupId>info.magnolia.module.bitbucket</groupId>
  <artifactId>bitbucket-restclient</artifactId>
  <version>1.0</version>
</dependency>

Configuration

To use this module, you have to configure a connection to Bitbucket by providing an OAuth consumer for the repository you want to use. Please follow the instructions to add an OAuth consumer:

Be sure to check the option 'This is a private consumer'.
bitbucket private consumer

To set up a REST client, please follow the steps below:

Add the REST client to the config.yaml file.

All parameters are required.
Parameter Description

apiKey

The client id from Bitbucket OAuth configuration.

apiSecret

The secret from Bitbucket OAuth configuration.

workspace

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: {workspace UUID}.

slug

This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: {repository UUID}.

authorizationUrl

Bitbucket url to obtain the access token.

Default = https://bitbucket.org/site/oauth2/access_token

The parameters apiKey and apiSecret is set in Magnolia’s Passwords app.

Usage

This integration provides a command that runs the rest call postToRepository. The command can be run from anywhere in Magnolia. We can use RestTemplatingFunctions to call the service as well.

The bitbucket-resources module adds an action to the Resources Files app allowing users to export a node to Bitbucket.

bitbucket export

Sample code

Calling the command:

Map<String, String> files = new HashMap<String, String>();
files.put("text.yaml", "here is some text");
files.put("folder1/folder2/text2.yaml", "this is a file inside a folder");
Map<String, Object> params = new HashMap<String, Object>();
params.put(BitbucketRestClientModule.REST_CALL_PARAMS, files);
commandsManager.executeCommand("default", "postToRepository", params);

Calling the Bitbucket REST client:

RestEasyClient client = (RestEasyClient) restClientRegistry.getRestClient(restClientName);
BitbucketRestClientService service = client.getClientService(BitbucketRestClientService.class);
...
    Map<String,String> files = (Map<String, String>) context.get(BitbucketRestClientModule.REST_CALL_PARAMS);
    Response response = service.postToRepository(bitbucketModule.getWorkspace(), bitbucketModule.getSlug(), convertFilesToFormString(files));
...

Changelog

Version Notes

1.0

Initial release of the module.

Feedback

Incubators

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the Bitbucket module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules