Hi,
I’m currently developing an add-on for Jira. This Add-on provides (among other functionality) two post functions:
- one to clone an issue to a specified project
- one to trigger one of two transitions, based on a JQL: If the issue appears in the JQL, transition a is triggered, if it doesn’t transition b is triggered.
Both of these work fine on their own, but combining them leads to a problem.
Our current situation is as follows: In the “Create” transition of an issue PostFunction 2 is applied, and the issue is transitioned from the initial status to one of two others. This works, if the issue is created manually.
If the issue is created by PostFunction 1 however, it is never found - even if it should be included in the JQLs results (and is when running manually at a later point in time).
Issue creation looks as follows:
MutableIssue clonedIssue = issueFactory.cloneIssue(issue);
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
IssueManager issueManager = ComponentAccessor.getIssueManager();
try {
boolean wasIndexing = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);
issueIndexingService.reIndex(clonedIssue);
ImportUtils.setIndexIssues(wasIndexing);
issueManager.createIssueObject(user, clonedIssue);
}...
The JQL is constructed as follow:
Query conditionQuery;
try {
conditionQuery = jqlQueryParser.parseQuery(noApprovalRequiredQuery);
if (JiraUtil.getIssuesFromJQL(searchService, conditionQuery, jiraAuthenticationContext).stream().anyMatch(it -> it.equals(issue))) {
return true;
}
Both work fine on their own, but when the JQL is triggered in the create transition (placed after the reindex function) the issue is never included in the JQL-Results, if it was created via the other post function.
I tried Thread.sleep for a second which didn’t change anything - it seems like indexing is started synchronously after the post function was triggered, even if it should start before.
Any help is appreciated,
Leo