Skip to main content
DevOps
Server
Jira

GAIN Capital

GAIN Capital standardises and controls Bitbucket operation with ScriptRunner.
Gain Capital logo

About GAIN Capital

GAIN Capital (part of the StoneX Group) is a US-based provider of online trading services. Founded in 1999, the company was among the early developers of online forex trading, and today serves more than 130,000 retail and institutional investors through their FOREX.com and City Index platforms.

Consolidating growth with Bitbucket

As GAIN grew, their need for coordination between tools and processes increased. The company was reliant on Jira to coordinate their business processes. But every development team that joined the company through expansion came with their own toolchain and different set-ups and rules. For version control alone, Team Foundation Server (TFS), GitHub and Bitbucket were being used in parallel.
They chose to consolidate with Bitbucket, because it not only integrates perfectly with Jira, but it is also easier to set up and use than TFS. Today, their Bitbucket has over 150 developers, working on 15 projects with more than 230 repositories - and the instance is growing rapidly.

"ScriptRunner for Bitbucket can do pretty much anything in the world"

Tomasz Bryla, Atlassian Specialist at GAIN Capital

The challenge

Ensuring developers follow best practices

GAIN operates in a heavily regulated market where even small slip-ups can have serious consequences. To offset that risk, the development teams’ consolidation effort had to go beyond tooling. In order to minimise risks and facilitate audits, GAIN needed to make sure that all developers followed the same company-wide rules and best practices.
"Generally, developers prefer barrier-free or minimal resistance during the software development life cycle. Anything that is not coding is seen as taking time away from the actual coding. Our challenge was to enforce compliance and uniformity in Bitbucket across the board without impinging on smooth operation." Nishaat Rajabali, Productivity Tools Team Manager at GAIN.
To achieve this, the Productivity Tools Team started looking for a way to ensure that, should a developer not follow the agreed-upon best practices when pushing code, the push would be automatically rejected.

The solution

Automated controls built into the development workflow

The extensive and bespoke automated controls required could not be set up with Bitbucket alone, and the team did not have the resources to write and maintain their own Java plugins. Enter GAIN’s Atlassian specialist Tomasz Bryla, who was a seasoned ScriptRunner developer for Jira, and introduced ScriptRunner to the Productivity Tools Team for Bitbucket.
Screenshot of Bitbucket controls

"We chose ScriptRunner as it is a well established plugin and we already rely on it heavily in Jira. It saved us from having to write a dedicated plugin that would have otherwise incurred future maintenance overhead. We can script our own pre-hooks and merge checks using Groovy, but it also has some very good bundled controls that saved us a lot of time."

Nishaat Rajabali, Productivity Tools Team Manager at GAIN Capital
Using ScriptRunner, we scripted and set up a series of pre-hooks that trigger automatically upon Git events such as ‘git push’ and run directly on the Bitbucket server without the option to disable them by users," says Tomasz.
Using ScriptRunner, GAIN Capital customised their workflow to include automated best practices enforcement tailored to the specific needs of the developers and the company.

Use cases

Here are some of the ways GAIN Capital use ScriptRunner:

Block Commits not associated with a Jira ID

Problem

To better link stories and build deployments, commit messages associated with a push operation must begin with a Jira ticket ID.

Solution

When a developer pushes code which does not begin with a Jira ticket ID in the commit message, the ScriptRunner pre-hook rejects the push with an error message pointing to the relevant wiki link detailing the rationale behind the control policy. To avoid blockages while the developers were getting used to the new ‘speed-bump’, the pre-hook was initially designed to warn users about the non-compliance, instead of rejecting the push outright.
After a few weeks, the pre-hook automatically rejected commits that didn’t have the Jira ticket ID in the message. Moreover, to accommodate break fixes, the pre-hook accepts a push with [EMERGENCY] in the commit message.
An illustration of a code editor full of scripts with an arrow hovering over a button

Block binaries from being pushed to repo

Problem

Binaries increase repo size, which swells disk space consumption and enlarges git clone time locally and in other systems such as on a CI/CD server. Destroying files and associated history in Git is not easy and discouraged, so binaries had to be rejected from the outset. Instead, they should be pushed to a binary repository like NuGet or Artifactory.
Screenshot of control information

Solution

The Productivity Tools Team created templates for gitignores, used by Git itself to detect binaries locally, but also in the server. Anything that is captured by the .gitignore is considered a binary and should not go into source control.
GAIN used a custom pre-hook that checks the push against the .gitignore. If it detects a binary, it returns an error message that’s linked to the documentation in Confluence which contains the guides on how to check for binaries and relocate them to binary repository.
Screenshot of gitignore-templates

The conclusion

GAIN developers started seeing increased traceability and context for each commit after the controls were set up. It’s now easier and faster to trace problems and anomalies across the entire development department, stopping them before they cause problems.
The binaries and file sizes controls not only sped up performance, but also saved the Productivity Tools Team the time spent cleaning up files and associated history in Git.

"ScriptRunner for Bitbucket can do pretty much anything in the world, which is perfect. Without it we wouldn’t have survived, scripting was essential. And Adaptavist has a very prompt and helpful support squad, they helped us do things we didn’t think were possible."

Tomasz Bryla, Atlassian Specialist at GAIN Capital

Discover how you can automate and control your DevOps workflow with the most powerful admin app for Bitbucket