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?
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
I hope this helps! Please let us know if you have any questions or any other problems with this.
Kind Regards
Yannis
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.