Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

MergeChecks script error

Kha Hoang May 17, 2023

We have the MergeChecks script in BitBucket and it has been working; however, after upgraded ScriptRunner to version 8.1.0, the script is broken and gave error:

# Script: get the merge from branch value and to branch value, split it by / and get the second value after splitted.  compare them and if the values are the same, allow the merge.

# e.g. toBranch = develop/asc  and fromBranch = feature/asc/<Jira-issue>

def toBranch = mergeRequest.pullRequest.toRef.displayId
def fromBranch = mergeRequest.pullRequest.fromRef.displayId

def str1;
def str2;

str1 = toBranch.split('/')[1];
str2 = fromBranch.split('/')[1];

if (str1 == str2) {
    return false;
} else {
    return true;
}
After upgraded ScriptRunner, It gave the following error.  How do we fix it?
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during semantic analysis: Expression [BinaryExpression] is not allowed: toBranch.split(/)[1]

java.lang.SecurityException: Expression [BinaryExpression] is not allowed: toBranch.split(/)[1]
	at org.codehaus.groovy.control.customizers.SecureASTCustomizer$SecuringCodeVisitor.assertExpressionAuthorized(SecureASTCustomizer.java:1084)
	at org.codehaus.groovy.control.customizers.SecureASTCustomizer$SecuringCodeVisitor.visitBinaryExpression(SecureASTCustomizer.java:1300)
	at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:60)
	at org.codehaus.groovy.control.customizers.SecureASTCustomizer$SecuringCodeVisitor.visitBinaryExpression(SecureASTCustomizer.java:1303)
	at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:60)
	at org.codehaus.groovy.control.customizers.SecureASTCustomizer$SecuringCodeVisitor.visitExpressionStatement(SecureASTCustomizer.java:1173)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
	at org.codehaus.groovy.control.customizers.SecureASTCustomizer$SecuringCodeVisitor.visitBlockStatement(SecureASTCustomizer.java:1137)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence, confluence for marketers, atlassian community events, ace, confluence training, confluence marketing workflows, atlassian learning, marketing tools, content marketing, marketing pm, atlassian live learning, confluence for teams​

Great marketing starts with Confluence. Join our live learning sessions to learn how! 📹

Join our 3-part live learning series with community leader Robert Hean to master how to leverage Confluence for Marketing teams. Learn how to plan and execute on projects seamlessly and how to turn insights into lasting organizational knowledge. 🧠

Register today!
AUG Leaders

Atlassian Community Events