Automation and Exalate

Originally asked by Jorge Jerez Ibáñez on 03 September 2020 (original question)


Hi

We’ve found a problem between exalate and Automation for Jira.
In our use case, exalate sync a instance with Jira Service Desk and an instance with Jira Software. We’ve discovered our problem in the next case:

When a issue is commented on Jira Service Desk, the issue get sync using exalate.On Software, we have an automation which, when the issue is commented updates the labels field. Our problem is when Automation updates the issue, Exalate has not finished the Sync, and sometimes, when the Sync finish, updates again the label, deleting the value introduced with automation.

We’re looking to fix that, as the other option is to buy automation for Service Desk instance, but we think we will have the same problem.

On what instance: Jira Data Center 8.5.3


Answer by Francis Martens (Exalate) on 03 September 2020

Our problem is when Automation updates the issue, Exalate has not finished the Sync

What are the conditions which trigger the automation rule?


Comments:

Jorge Jerez Ibáñez commented on 04 September 2020

As I said: “when the issue is commented updates the labels field”

So comment is the trigger

Francis Martens (Exalate) commented on 04 September 2020

We checked internally.
On Jira server, Exalate is not generating events when ‘pairing’ an issue (this is the operation which create an issue), and in case of updates, events are generated by jira.

To test this out (we can be wrong of course), I added a custom script listener using the script runner - printing out the generated events

So when pairing - no event is generated
When syncing a comment - an issue comment is generated.

Bottomline - we are currently clueless where the problem is incepted.

Jorge Jerez Ibáñez commented on 14 September 2020

The event “Issue commented” is generated 100% (Automation is being executed).
The problem becomes when the automation edit the issue when exalate is still doing the sync. Automation add a value to a field, but sometimes this fields is not sync and exalate sync it before Automation edit it, so the value written by automation just disappears.

Could you try to test our use case?

Francis Martens (Exalate) commented on 14 September 2020

Another customer raised a similar problem where 2 events are generated when doing a comment + transaction in a single script.

We are investigating.

Jorge Jerez Ibáñez commented on 21 September 2020

Hi Francis

Do we have any news about this?

Francis Martens (Exalate) commented on 22 September 2020

We have a scenario allowing to reproduce the problem - further investigating.

Jorge Jerez Ibáñez commented on 13 October 2020

Hi Francis Martens (Exalate)

Any news?

We’re going to use Exalate on a new customer and we’re afraid about facing issues with Automation as it is a usually used plugin on Jira Server.

Jorge Jerez Ibáñez commented on 12 November 2020

Hi Francis Martens (Exalate)

Out customer still waiting for this as they need to use automation for fix some problems. Do we have any good news?

Francis Martens (Exalate) commented on 12 November 2020

The problem is still outstanding. It looks like a difficult problem because fixing it, is creating a regression in an other use case. :headscratch:

Jorge Jerez Ibáñez commented on 12 November 2020

If we can help you in any way, feel free to ask

Francis Martens (Exalate) commented on 12 November 2020

Thanks for the offer.
It is pretty internal

Francis Martens (Exalate) commented on 24 November 2020

Hi Jorge Jerez Ibáñez

We were discussing the case today.
One of the workarounds is to remove any update of the labels from the incoming script
Avoid assigning to issue.labels

Not sure if this helps - let me know

Jorge Jerez Ibáñez commented on 07 December 2020

I could be a way to resolve the problem.
I’ll talk about this with our customer but I don’t think it will good for us as sometimes labels are added on Jira Service Desk and they need to be sync.

Francis Martens (Exalate) commented on 07 December 2020

The statement

issue.labels = replica.labels

is going to overwrite all the labels.
If you need to merge the labels, a more specific logic needs to be handed

For instance following snippet might be a help

def a = [ 1, 2, 3, 4 ]
def b = [ 2, 4]


println a + b
println a  + b.findAll{! a.contains(it)}

Try it out on https://groovyconsole.appspot.com/

It results in

Jorge Jerez Ibáñez commented on 10 December 2020

So we can use these statement into the Exalate script?

Jorge Jerez Ibáñez commented on 17 December 2020

Would this work?

issue.labels = issue.labels + replica.labels.findAll{! a.contains(it)}

We can’t test it actually