How to enforce naming conventions using ScriptRunner add-on with Bitbucket

Mary Slocum July 2, 2018

Hello,

Using ScriptRunner add-on 5.1.8 with Bitbucket 5.3.2, is there a way to enforce naming conventions for projects and repos? If so, how?

I see that there is enforcing naming conventions for feature and bugfix branches using the Pre-receive Hooks, but is there anything for project and repo names?

Thanks,

Mary

2 answers

1 accepted

0 votes
Answer accepted
adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2018

You could do that using a custom event handler.

For example you can use the following script for the ProjectCreationRequestedEvent. You'll need to change the regex part. At the moment it enforces that project keys must begin with a C followed by at least one upper case character in A-Z.

def regex = "C[A-Z]+"

if (! (event.project.key ==~ /${regex}/)) {
event.cancel("Project key must start with C!")
}

Let us know how that goes.

Mary Slocum July 4, 2018

Works great! Thank you so much for your help :)

 

Mary

0 votes
adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2018

Hi Mary,

There is an event handler for that using ScriptRunner. It's called "Naming standard enforcement" with the description "Enforce project and repository naming standards".

The documentation can be found here but it's works similarly to the branch and tag naming convention one.

Let us know how you get on.

Thanks,
Adam

Mary Slocum July 3, 2018

Thanks, Adam!

I was on an older version, so I didn't see that available.

But, is there a way to enforce a naming convention for the Project Key? I'm now fine with the Project Name being descriptive, but I need to enforce a naming convention on the Project Key.

Mary

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events