How to handle issue update/index timing in listener plugin?

I'm writing a Listener plugin that will update some related issues at the time when the relationship is created or removed between the two issues. I am running a JQL search to determine the data needed to populate on these related issues. However, i've run into an issue suddenly regarding the time delay of the updates to the triggering issue and when those updates are available to be queried.

So, my listener runs the query but only sees related information as if there were no change to the issue causing this trigger (in the case of removal, the relationship still seems to be there).

I'm wondering if there is a Order of Operations document, or a way to force a delay in when the listener will actually run compared to when the event is thrown.

It seems like i'm running into a problem where the indexing of the issue being changed which is throwing the event and therefore triggering the listener is not completing in time for the JQL query to return the correct up-to-date results from the index.

Let me know if anyone else has run into this and if there is a workaround or if i'm just left to my own devices in order to handle the exceptions in code.


1 answer

Hi Adam,

I did something similar recently where I created a jelly script closing tickets that are linked to.

Instead of running to query within the listener, I have created a saved/shared filter and run that via Jelly. See the snippet of that below. It works like a charm.

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >
<jira:Login username="someuser" password="somepassword">
    <log:info>Running Close issues service</log:info>
    <!-- Properties for the script -->
    <core:set var="comment">This ticket is closed as it is deployed to PROD. See the linked ticket for deployment above under Issue Links section.</core:set>
    <core:set var="workflowStep" value="261" />
    <core:set var="workflowUser" value="someuser" />
    <core:set var="ClosedasD2PCM" value="18133" />
    <!-- Run the SearchRequestFilter -->
    <jira:RunSearchRequest filterid="${ClosedasD2PCM}" var="issues" />
    <!-- Iterate over the issues -->
    <core:forEach var="issue" items="${issues}">
        <log:warn>Closing issue ${issue.key}</log:warn>
        <jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" comment="${comment}" resolution="Deployed to PROD"/>

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,655 views 18 21
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you