I need to build and execute a JQL in a script listener to search for certain words in the Description field in JIRA. For instance, once I obtained the values for param1, param2, and param3 (I know how to do the parsing), I need to build a JQL and excute it to search for all Jira issues where the description fields contains all three values, like this:
description ~ param1 AND description ~ param2 AND description ~ param3
Thank you for your assistance
Hi Alexey...thank you so much for your assistance. This is really helpful. I am still struggling with this line of the code:
def query = jqlQueryParser.parseQuery("description ~ param1 AND description ~ param2 AND description ~ param3")
How do I specify that I need the JQL to execute with the value in param1/param2/param3 and not the words param1/param2/param3?
Thank you for your help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could write like this
def param1 = getYourParam1();
def param2 = getYourParam2();
def param3 = getYourParam3();
def query = jqlQueryParser.parseQuery("description ~ " + param1 + "AND description ~ " + param2 + "AND description ~ param3")
Then you would need to decide where you would store your parameters.
And you have many choices:
You could:
store it in the file system near your script
store in a custom field for each issue
store as an issue property
store as a project property
store it in SAL
store it in a database
and so on
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexey...thank you for your assistance...I finally had the time to test this out but it is still not working...the issue is with the line with the JQL...I am parsing the summary of the issue being created and I am properly getting param1, param2, and param3 but building the JQL is not working...it gives a syntax error...and also param1, param2, param3 may be JIRA reserved words as well. So for instance, if param1 = account-authn, param2 = access, and param3 = 1.5.0, the following line works fine:
def query = jqlQueryParser.parseQuery("description ~ 'account-authn' and description ~ 'access' and description ~ '1.5.0'")
but of course I need this to be with the values in param1, param2, param3
Here is the error I got:
com.atlassian.jira.jql.parser.JqlParseException: com.atlassian.jira.jql.parser.antlr.RuntimeRecognitionException at com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseClause(DefaultJqlQueryParser.java:96) at com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseQuery(DefaultJqlQueryParser.java:32) at com.atlassian.jira.jql.parser.JqlQueryParser$parseQuery.call(Unknown Source) at Script7.run(Script7.groovy:36) Caused by: com.atlassian.jira.jql.parser.antlr.RuntimeRecognitionException at com.atlassian.jira.jql.parser.antlr.JqlLexer.checkAndSet(JqlLexer.java:100) at com.atlassian.jira.jql.parser.antlr.JqlLexer.mSTRING(JqlLexer.java:1676) at com.atlassian.jira.jql.parser.antlr.JqlLexer.mTokens(JqlLexer.java:2656) at org.antlr.runtime.Lexer.nextToken(Lexer.java:85) at org.antlr.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:143) at org.antlr.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:137) at org.antlr.runtime.CommonTokenStream.consume(CommonTokenStream.java:71) at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:106) at com.atlassian.jira.jql.parser.antlr.JqlParser.operator(JqlParser.java:1214) at com.atlassian.jira.jql.parser.antlr.JqlParser.terminalClause(JqlParser.java:645) at com.atlassian.jira.jql.parser.antlr.JqlParser.notClause(JqlParser.java:555) at com.atlassian.jira.jql.parser.antlr.JqlParser.andClause(JqlParser.java:432) at com.atlassian.jira.jql.parser.antlr.JqlParser.orClause(JqlParser.java:366) at com.atlassian.jira.jql.parser.antlr.JqlParser.clause(JqlParser.java:328) at com.atlassian.jira.jql.parser.antlr.JqlParser.query(JqlParser.java:237) at com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseClause(DefaultJqlQueryParser.java:89) ... 3 more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It must be
def param1 = "account-authn"
def param2 = "access"
def param3 = "1.5.0"
def myQuery = "description ~ \"" + param1 + "\" AND description ~ \"" + param2 + "\" AND description ~ \"" + param3 + "\""
log.error(myQuery)
def query = jqlQueryParser.parseQuery(myQuery)
Kindly check in the logs that myQuery is correct
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are the man!
Thank you so much for your help Alexey!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alexey Matveev need your help i need to pass parameters in cmd line for jql query
HOW TO ACHEIVE THAT
# set up the JQL query to search for issues
jql = 'project = XXXXXINT AND status = "To Do"'
# set up the parameters for the search request
params = {
'jql': jql,
'maxResults': 50,
'fields': 'summary,issuetype,assignee,status,reporter,description,created'
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@alexey the out put execution in cmd should be like jiraQuery.py XXXXXINT To Do
to pass parameters like above in cmd line what needs to be done in my python script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.