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

How to prevent merge at certain times of the week

Hi, I tried to use Conditional merge check to prevent merge  after 1 PM on Tuesday but I failed. I wrote the codes below in ScriptRunner and I got a lot of Static type checking errors like "Script15.groovy: 1: [Static type checking] - You tried to call a method which is not allowed: java.util.Calendar#getInstance()".

def cal = Calendar.instance
TimeZone tz = TimeZone.getTimeZone("Asia/Tokyo");
cal.setTimeZone(tz);
def hour = cal.get(Calendar.HOUR_OF_DAY)
Calendar.TUESDAY == cal.get(Calendar.DAY_OF_WEEK)&&hour >= 13

It seems that Calendar can't be used here and I want to know is there any other way to prevent merge at certain times of the week?

1 answer

Hi @DanielTian 

Did you try to create this merge check from the project or repository settings screens, instead of the global bitbucket admin screen? You should use the second option as the other screens are accessible to non-admins, and are executed in a more restricted sandbox.

You could log in as an admin, go to the merge checks through the Scriptrunner admin screen (under ../plugins/servlet/scriptrunner/admin/mergechecks), and create a new 'Conditional Merge Check`, using the 'Projects / repositories' field and paste the same script you provided here. It should work without errors

 

Screenshot 2022-09-13 at 17.36.58.png

Screenshot 2022-09-13 at 16.44.06.png

 

I hope this helps! Please let us know if you have any questions or any other problems with this.

Kind Regards

Yannis

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events