Forums

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

Increment a custom field with jira-python from services running asynchronously

Shay Yacobinski
Contributor
December 22, 2019

Hi all,

I have a custom field in a task that I want to increment by 1 by a remote service.
That service will have several instances running asynchronously, and each needs to increment the field by 1 when it's done. The field represents the number of times the services ran. Once the field reaches a certain value the task will transition to the next status.

The only option I've found is to get the field's value, increment it by 1 and update it.
My issue with this solution is that it is not thread-safe and the services updating the field may retrieve false values.

Is there a better solution?
Is it possible to use a different mechanism or something other than a counter field to achieve the same result?

Thanks

1 answer

1 accepted

0 votes
Answer accepted
brbojorque
Community Champion
December 22, 2019

Hi @Shay Yacobinski ,

It does not make much sense to do the count on the issue level. 

My approach would be to:

  • Do the counting in the script/service and when it reached a specific count you then transition the ticket.
  • So the only action to be performed by the ticket is transitioning and not updating the value.
  • Add a comment when it is successfully transitioned.

Let me know if it makes sense.

Suggest an answer

Log in or Sign up to answer