Scripted JQL function to check issuetype1.fixversion = issuetype2.fixversion

Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2014

I have a requirement from the client where we need to compare fix version for 2 different types of issuetype.

Eg: Bug.fixversion > Task.fixversion. 

Can this be done using scripted jql function? If yes how can we accommodate more than one fix versions which are selected for the issue type.

3 answers

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2014

So there is a relationship between PBI and SAR, perhaps through an issue link? At its simplest, this just involves querying for PBIs, finding their linked SAR, and comparing the two fields.

If there are multiple fix versions, you should find out what the client actually wants to happen. I would work out all the cases and permutations before you start implementing.

Also think how to compare two versions... do you want to compare by sequence, by release date, or using semantic versioning rules? Anyway, it's all perfectly doable.

Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 9, 2014

Thank you Jamie. PBI and SAR are linked together using the structure. The comparison between all the fix versions for this issue types should happen through release date. Can you please help me in writing scripted jql query for this?How should the query be?

Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2014

Hi Jamie Request your help ..

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2014

You want me to write it for you? That's not going to happen. Just make a start and ask specific questions when you get stuck.

Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2014

no not write. among the list of issue functions which you have written. which is the closest one where i can try? because i tried it for the Query for PBI.SomeDateField > SAR.SomeDateField . But for the first one since there are more than 1 fix version per issue i am not sure how to compare the complete fix version list with the other

Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2014

Hi Jamie.. I have wriiten the script by referring your code on date compare. class GetIssues extends AbstractScriptedJqlFunction { def String subquery String releaseDate private def String dateParams private def op @Override MessageSet validate(User user, FunctionOperand operand, TerminalClause terminalClause) { def messageSet = new NumberOfArgumentsValidator(1, 1, getI18n()).validate(operand) //eg deadline>fixversion def dateStr = operand.args[0] messageSet.addMessageSet validateDateComparison(dateStr) if (messageSet.hasAnyErrors()) { messageSet.addErrorMessage("Use comparison like > or <") } op = dateParams } MessageSet validateDateComparison(String dateStringOperator) { def messageSet = new MessageSetImpl() try { dateParams = dateCompareParser(dateStringOperator) } catch (Exception e) { messageSet.addErrorMessage(e.message) } messageSet } public String dateCompareParser(String param) { if (! (param =~ /[<>]/)) { throw new Exception("The comparison must contain a either > or < .") } op = param } /** * Implement this method for using datatype = IssueFunction * Delete it otherwise * @param queryCreationContext * @param operand * @param terminalClause * @return lucene query */ Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) { validate(queryCreationContext.user, operand, terminalClause) def booleanQuery = new BooleanQuery() def versionManager = ComponentAccessor.getVersionManager() def versions = versionManager.getAllVersions() def customFieldManager = ComponentAccessor.getCustomFieldManager() CustomField deadlineCustomField = customFieldManager.getCustomFieldObjectByName("Deadline") def match Set issueIds = new HashSet() for(Version v in versions) { releaseDate =v.getReleaseDate() if(op==">") { match = deadlineCustomField>releaseDate } else if(op=="<") { match = deadlineCustomField<releaseDate } if(match) { } } } } i need to write a issue function like dateCompare(Deadline > FixVersionReleaseDate) This query is fixed and wont change. So i am just getting the operator either > or <. Then i get release date for all versions in jira & all deadline and compare these two date fields and fetch only those issues which match the criteria. I have written down something but i dont know how to fetch the issues. Is this logic somewhat correct.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2014

Reasonably, other than you're not returning anything. I think you should be able to use linkedIssuesOf to get all PBIs or whatever, and then do the version comparison...

Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2014

Thanks Jamie for replying. I didnt get "use linkedIssuesOf" . Did you mean to say that instead of using the above script use linkedIssuesOf or use this along with the script above.? Also these issues are linked to another type of issue using "structure" can this jql function work for this? Because these are the set for the available links Available links are: [Defect on, Defects infused, is Epic of, has Epic, FF-depends on, is FF-depended by, FS-depends on, is FS-depended by, Link To, Link From, SF-depends on, is SF-depended by, SS-depends on, is SS-depended by] . Where does Structure fit in here

Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2014

Also Jamie how can i modify the existing code which i have pasted above to pass the issue ids which satisfy the criteria. I mean how to make the function return the matching issues? if(match) { //need to flush out issue ids }

0 votes
Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2014

Sorry there was a typo in the above question just edited it. We have 2 types of issues in our system PBI and SAR. SAR is like topmost and then we have PBI . Each have their own set of fix issues. So the client wants a query by which they can compare the fix versions for this issue. This is purely for their management related activity. I have actually no idea about the exact requirement as of now. So they have given 2 such requirements: 1)Query for PBI fixVersion > SAR fixVersion 2)Query for PBI.SomeDateField > SAR.SomeDateField

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2014

I'm sure you can but what is your requirement exactly. Can you give an example? It's not at all clear.

Suggest an answer

Log in or Sign up to answer