Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Preventing changes to specific file/line/variable

Hey,

I need to prevent merging to a specific branch any pull requests that include a change to a specific Python variable.

Is it possible to do this? Maybe just for a specific line or a specific file? Or maybe instead of preventing the merge, add an alert? 

Thanks!

2 answers

0 votes
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 01, 2021

It may be a bit heavyweight for your use case, but you could:

  1. Create a commit policy with the Changed paths (files) must match a pattern condition. It will reject changes made on the configured set of files. (It will not check the content of the file though.)
  2. Install it as a local pre-commit hook to every developer's local clone.

That way, developers won't be able to create a commit to that file, so this approach catches the problem early on.

(Disclaimer: this solution requires a paid Jira app that I'm working on.)

condition-file-pattern.png

0 votes
Ulrich Kuhnhardt _IzymesCo_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
Oct 31, 2021

The best option to stop a PR merge under a certain condition would be to create a configurable merge-check. The merge-check would scan the change set in the source branch and detect any condition you configure.

Unfortunately this is not possible with bitbucket cloud branch permissions - however there is an existing feature request https://jira.atlassian.com/browse/BCLOUD-19885 that would allow you to create such a merge-check. Please vote and add yourself as a watcher.

Best, Ulrich

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events