Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

When is a Jira issue updated through the course of its post functions' run

Azeus System Team October 30, 2018

I have a transition with 8 post functions. Here is the sequence of the post functions:

1.  Update Any Issue Field (JSU) - updates customfield_A value to %%CURRENT_USER%%

2.  Update Any Issue Field (JSU) - updates customfield_B value to %%CURRENT_DATETIME%%

3-7. All the five essential post functions

8. Custom script post function (Adaptavist) - gets the issue key then runs a script in the local Jira server which includes using the key to curl for the current issue JSON

 

Now the problem is, post function no. 8 acquires the issue JSON of the previous issue state (not status), meaning customfield_A and customfield_B still have null values. I tried putting sleep before the curl command to check whether Jira needs time to update the issue (while also increasing the waitFororKill of the groovy script) to no avail.

I also tried this scenario to confirm that the previous state is what's being curled:

a. User1 performs the transition from statusX to statusY at time1 - customfield_A and customfield_B returns null

b. Looped back from statusY to statusX

c. User2 performs the transition from statusX to statusY at time2 - customfield_A has a value of User1 and customfield_B has a value of time1

 

My question is, is this a problem with my post function arrangement or is this an expected behavior?

 

1 answer

0 votes
Nic Brough -Adaptavist-
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.
October 31, 2018

In point 8, the post-function has direct access to both the old and new values on the issue, so I'm not sure why you are issuing a curl to fetch the old data.

Azeus System Team October 31, 2018

Hello Nic. I am actually trying to fetch the new data but what I end up getting is the old data. For getting the new values on the issue, I want to get the whole issue detail in JSON format and place that in the local Jira server. I'm not sure if there's a way to do that in script runner but what I've tried so far is just getting fields one by one, and I don't exactly want to list all the custom fields in the groovy script. Thank you.

Nic Brough -Adaptavist-
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.
October 31, 2018

Yes, that's because you're getting existing data before it is updated.

I don't understand why you are trying to get it at all, when the post-function has direct access to both old and new data.

Suggest an answer

Log in or Sign up to answer