I have a script which first creates a bunch of issues via something like:
issueService = ComponentAccessor.getIssueService()
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setIssueTypeId(issueTypeId)
issueInputParameters.setProjectId(projectId)
issueInputParameters.setSummary(summary)
issueInputParameters.setReporterId(user.getName())
CreateValidationResult createValidationResult = validateIssue(user, issueInputParameters)
if(createValidationResult == null)
{
return null
}
else
{
IssueResult createResult = issueService.create(user, createValidationResult)
}
and then does a query searching for the created issues:
def queryTemplate = "issueFunction in hasLinks(\"References ONE\") and issue in linkedIssues(${one.key}) and issue in linkedIssues(${homeNet.key})"
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def compiledQuery = jqlQueryParser.parseQuery(query)
log.debug "${query}"
ApplicationUser user = "myUser"
SearchResults searchResults = searchProvider.search(compiledQuery, user, PagerFilter.getUnlimitedFilter())
When run, the script creates the issues correctly, but these are not available to the JQL query (searchResults returns empty result), this until a second execution of the same code is run.
It seems in other words that the issues are persisted at script's execution end so I need to run the code two times for the issues to be available via JQL query.
You have to do reindex explicitly after you create the issues and before you search by jql.
boolean wasIndexing = ImportUtils.isIndexIssues() ImportUtils.setIndexIssues(true) ComponentAccessor.getIssueIndexManager().reIndex(issue) ImportUtils.setIndexIssues(wasIndexing)
Regards
Prakhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I added a reindex as you suggested, below is the non-deprecated version of your code:
boolean wasIndexing = ImportUtils.isIndexIssues()
ImportUtils.setIndexIssues(true)
IssueIndexManager indexManager = ComponentAccessor.getComponent(IssueIndexManager)
indexManager.reIndex(issue)
ImportUtils.setIndexIssues(wasIndexing)
however the problem persists, I'm afraid the problem is the re-indexing of the linked issues. In my code I create a new Issue and two links to other issues, the JQL as I previously posted is the following:
"issueFunction in hasLinks(\"References ONE\") and issue in linkedIssues(${one.key}) and issue in linkedIssues(${homeNet.key})"
I'm afraid the problem is the reindexing of all links created.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you try to use reIndex with IssueIndexingParams? It gives you the ability to index issue related metadata also. You can also use IssueIndexService instead of IssuIndexManager as I see the later is being deprecated. But at this moment both should work.
Here is the api description :
If it also does not solve then I fear you have to use reindexAll().
Regards
Prakhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I added a:
IssueIndexManager indexManager = ComponentAccessor.getComponent(IssueIndexManager)
indexManager.reIndexAll()
and the JQL fails, if I run the same query from web console it returns the correct result, same if I rerun the script after the issue and linked issues have been created.
should I get worried?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you add a check if the reindex is complete ?
Run jql only after reindex is complete.
Regards
Prakhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
IssueIndexingService indexService = ComponentAccessor.getComponent(IssueIndexingService)
long reindexTime = indexService.reIndexAll()
await(reindexTime)
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.
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.