Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner for Bitbucket - Auto-add reviewers PRs with changes to specific paths

I've been using ScriptRunner for Jira for a long time now, but I've just started using ScriptRunner for Bitbucket and I'm having some issues trying to figure out how to write conditions properly. I'm currently trying to add a condition to auto-add a particular user as a reviewer for a PR if there are changes to a specific path using the "Auto add reviewers to pull requests" event handler (documented here).

For testing, I'm just trying add myself as a reviewer. This is current groovy script I'm using as a condition:

pathsMatch('glob:repo/path/to/file/**') || pathsMatch('glob:repo/other/path/for/auto/add/**')

I have also tried this:

def pullRequest = event.pullRequest

pullRequest.pathsMatch('glob:repo/path/to/file/**', pullRequest.getCommits()) || pullRequest.pathsMatch('glob:repo/other/path/for/auto/add/**', pullRequest.getCommits())

These scripted conditions aren't working for me, though. Am I using an incorrect syntax? I also don't understand if I'm supposed to be include the repo name or not if this script event handler is configured on a single repo.

1 answer

1 accepted

0 votes
Answer accepted

I was able to figure this out. The syntax inside the pathsMatch() function should not include the repo name as part of the path name. In my first example above, I just shouldn't have included "repo" in the path name.

I also realized that the reviewer is added to the "Reviewers" field before the PR is actually created, not after, so that was helpful in troubleshooting. I was also trying to add myself as a reviewer to my own PRs, but you can't add yourself as a reviewer on your own PRs, so that was another issue. :)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

All you wanted to know about customer support KPIs

When working in customer support, it’s crucial to calculate, analyze and monitor specific numbers, called KPIs (Key Performance Indicators). They go hand-in-hand with customer satisfaction, problem d...

107 views 1 5
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you