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
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
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");
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?
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
I hope this helps! Please let us know if you have any questions or any other problems with this.