Restrict jira issue use in one bitbucket repo

Is it possible to restrict the use of an issue in jira server in only one repository in bitbucket, in other words we can't use the issue in other repositories ?

1 answer

It's possible, but it's not easy.

You'd have to write your own global push hook, similar to Yet Another Commit Checker's global hook.

In your hook's onReceive() method you would extract JIRA ticket references from the commit messages, and then use Bitbucket's built-in JIRA index to see if any previous commits already referenced them.

@ComponentImport
private final com.atlassian.bitbucket.idx.CommitIndex commitIndex;

In particular, you would call the CommitIndex.findByProperty() method to see if any commits in any repos referred to the given JIRA ticket:

String jiraKey = "TKT-123";
PageRequest pr = new PageRequestImpl(0, 999);
Page<IndexedCommit> pageResult;

pageResult = commitIndex.findByProperty(
JiraConstants.IDX_PROP_ISSUE_KEYS, jiraKey, false, pr);

 

Note: a naive implementation of this would potentially block all new commits that referenced "UTF-8" or "ISO-9000", since Bitbucket assumes those are JIRA tickets.   Bitbucket does not check if a given "ticket-like" string in a commit message actually exists in your JIRA instance.  It just indexes all "ticket-like" strings regardless.

 

IS there a possibility to do it with a hook ( bash commands )

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

699 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot