You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I am having a lot of issues or not understand enough about how to implement the pre-hook in BitBucket using ScriptRunner. I have many but following are the first 3 cases:
we are using this kind of branching scheme:
develop/proj1/feature/[A-Z]{2,9}-\d+.*
develop/proj2/feature/[A-Z]{2,9}-\d+.*
develop/proj3/feature/[A-Z]{2,9}-\d+.*
release/proj1/feature/[A-Z]{2,9}-\d+.*
release/proj2/feature/[A-Z]{2,9}-\d+.*
release/proj3/feature/[A-Z]{2,9}-\d+.*
master/proj1/feature/[A-Z]{2,9}-\d+.*
master/proj2/feature/[A-Z]{2,9}-\d+.*
master/proj3/feature/[A-Z]{2,9}-\d+.*
The pre-hook for Branch and tag naming standards enforcement seems to work fine in the statement: master/feature/(proj1|proj2|proj3)/[A-Z]{2,9}-\d+.*
Case 1:
The Require commits to be associated with a valid Jira issue doesn't work in the JQL clause template: (issuetype = feature OR issuetype = Story OR issuetype = Bug OR issuetype = Sub-Task) AND (status = 'In Progress' OR status = 'In Review'))
Case 2:
It also doesn't work for Require that pull request associated with a valid Jira issue:
Condition: (mergeRequest.pullRequest.fromRef.displayId.matches("release/.*") || mergeRequest.pullRequest.fromRef.displayId.matches("master/.*")) &&
!(mergeRequest.pullRequest.toRef.displayId.matches("develop/.*") || mergeRequest.pullRequest.toRef.displayId.matches("feature/.*"))
Cases 1. 2. Can I confirm if you already set up the Jira application link as documented in Adaptavist site?
Case 2. Following part of your condition:
mergeRequest.pullRequest.toRef.displayId.matches("feature/.*"))
probably should be:
mergeRequest.pullRequest.toRef.displayId.matches(".*/feature/.*"))
Please note that: the condition is not for a condition to reject a pull request, instead it is a condition to check for valid Jira issue.
Case 3. You can create a "Conditional merge check" that use similar condition in your case (2). Just be mindful that: In your condition, "fromRef" refers to source branch, "toRef" refers to target branch.
I hope this helps.
Thank you so much for your response.
Case 1. 2. Yes, Jira application link was established and is working properly.
Case 2. I will try that to see if it will work; however, I think it may still not know the Jira issue information because of the complexity level of the branch.
For Case 3. I did something like this it seems to work but I'm not sure if it's working correctly yet:
def toBranch = mergeRequest.pullRequest.toRef.displayId
def fromBranch = mergeRequest.pullRequest.fromRef.displayId
def str1 = toBranch.split('/')[1];
def str2 = fromBranch.split('/')[1];
if (str1 == str2) {
return false;
} else {
return true;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.