Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Limit Branches size name using pre-hooks

Margaria Vince December 6, 2022

Hello, as the title says i'm looking for a way to limit the name of bitbukets branches to 50 characters.  Do you know any way ? i'm trying to do a bash script using Scriptrunner to make this as a pre-hook but i can't manage to make it work.

1 answer

1 accepted

0 votes
Answer accepted
Aron Gombas _Midori_
Community Champion
December 7, 2022

With the Better Commit Policy app, you can implement a rule which matches the branch name against a regular expression. The regex can limit the number of chars to 50 (and do a million of other things).

The left-side example shows a similar use case with branch names:

rejected-tag-branch.png

See:

  1. The app: https://marketplace.atlassian.com/apps/1214430/better-commit-policy-for-bitbucket?hosting=server&tab=overview
  2. The related doc: https://midori-global.com/products/better-commit-policy-for-bitbucket/server/documentation/#verifying-branches-and-tags-created-in-bitbucket
  3. You have to use this condition: https://midori-global.com/products/better-commit-policy-for-jira/server/documentation/#branch-pattern-condition
  4. Here is a sample regex that requires a text be at least N chars: https://midori-global.com/products/better-commit-policy-for-jira/server/documentation/best-practices#commit-message-length (you should be able to figure out yours based on this)

(Discl. I'm a developer working on this paid and supported app.)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events