JQL解析异常错误:无法在ScriptRunner中执行JQL查询以打印摘要字段具有特定值的问题数

z0qdvdin  于 2022-11-01  发布在  其他
关注(0)|答案(2)|浏览(181)

我尝试在script runner中执行一些代码,以了解有多少问题具有特定值作为摘要。代码应该非常简单和直接,但我遇到了JQLParseException。我正在查找摘要字段中具有值“aa”的所有问题。我在日志文件中遇到此异常:

2022-08-05 15:18:52,115+0200 https-openssl-nio-443-exec-22 WARN mouh 918x48846x1 19eejnp 10.248.75.214 /secure/CommentAssignIssue.jspa [atlassian-jira.log] myyy exception: com.atlassian.jira.jql.parser.JqlParseException: com.atlassian.jira.jql.parser.antlr.RuntimeRecognitionException: NoViableAltException(59@[])

我还在Jira中执行了查询,它返回了274个结果,因此它应该可以运行

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.opensymphony.workflow.InvalidInputException;
import com.softwareag.jira.insight.helper.Helper;
import java.sql.ResultSet;
import java.util.Map;
import com.atlassian.jira.project.version.Version;
import com.atlassian.jira.workflow.function.issue.AbstractJiraFunctionProvider;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.workflow.WorkflowException;
import groovy.sql.GroovyRowResult
import groovy.sql.*
import groovy.sql.Sql
import java.sql.*; 
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;
import org.ofbiz.core.entity.ConnectionFactory;
import org.ofbiz.core.entity.GenericEntityException;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter

log.warn("HELLO 111")       

def log = Logger.getLogger("atlassian-jira.log")


def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
log.warn("MOUNA 3 ")
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
log.warn("MOUNA 4 ")

def issueManager = ComponentAccessor.getIssueManager()
log.warn("MOUNA 5")

// edit this query to suit
// I am looking for all issues with value "aa" for the summary field
def myquery = "summary ~ aa" 
log.warn("total issues  "+ myquery)

try{
def query = jqlQueryParser.parseQuery(myquery)

}catch (Exception e){
    log.warn("myyy exception: "+e)
}
pobjuy32

pobjuy321#

用单引号'将摘要字符串括起来应该可以解决这个问题。
def myquery = "summary ~ 'aa'"

5tmbdcev

5tmbdcev2#

我找到了解决办法,应该是这样的
def query = jqlQueryParser.parseQuery("summary ~ \'" + customDiagnoserId + "\'")

相关问题