Bitbucket Integration module

Edition

Incubator (services)

Issues

Git

Git

Latest

1.0

Compatible with Magnolia 6.2.

The Bitbucket integration module allows you to add, modify, and delete files from a Bitbucket repository. The module has 3 rest clients, one JCR config based client, and two other clients for authentication and connection using the new Magnolia 6.2 configuration based on yaml files.

This module shows how you can use either JCR or yaml to configure your rest clients. It 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

In order to use this module you need to configure the connection to Bitbucket. On Bitbucket you will need an OAuth consumer for the repository you want to use, you can follow the instructions here.

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

The following configuration is for the JCR configured rest client. Configuration can be set in the config.yaml file. The apiKey and apiSecret is set in the passwords app.

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

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 since this module is a show case for the old and new way of configuring rest clients.

The bitbucket-resources adds an action to the resources app, it will show the export to Bitbucket action when new content is added from the resources app.

bitbucket rest usage

Sample code

This is some 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);

Changelog

Version Notes

1.0

Initial release of the module.

Feedback