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

Adam Barylak
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.
June 10, 2014

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.

Thanks.

1 answer

0 votes
Mehmet Kazgan
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.
June 10, 2014

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"/>
    </core:forEach>
</jira:Login>
</JiraJelly>

Suggest an answer

Log in or Sign up to answer