Automation for Jira - Actions are duplicated when the Field Value Changed is triggered

プラットフォームについて: Data Center - この記事は、Data Center プラットフォームのアトラシアン製品に適用されます。

このナレッジベース記事は製品の Data Center バージョン用に作成されています。Data Center 固有ではない機能の Data Center ナレッジベースは、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。

*Fisheye および Crucible は除く

要約

The automation rule is triggered and executed successfully but sometimes actions are getting duplicated. This article is to troubleshoot why the sample rule triggers the action twice.

環境

  • 8.0.0 以降の任意のバージョンの Jira Server/Data Center
  • Automation For Jira (A4J) on any version

診断

  • The automation rule is configured with:
    • The Field value changed trigger with the "Issue Type" field as the Field to monitor for changes:

    • Any action (For example: Comment on the issue, Create an issue, etc...):
  • Here's the JSON export of the rule used to replicate the issue addressed in this article:

    {"rules":[{"id":1,"clientKey":"com.codebarrel.tenant.global","name":"Comment issue when issue type has changed","state":"ENABLED","canOtherRuleTrigger":false,"notifyOnError":"NEVER","authorAccountId":"JIRAUSER10000","actorAccountId":"JIRAUSER10000","created":1732293543863,"updated":1732297872872,"trigger":{"id":"17","component":"TRIGGER","schemaVersion":2,"type":"jira.issue.field.changed","value":{"synchronous":false,"fields":[{"value":"issuetype","type":"field"}],"actions":[]},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},"components":[{"id":"18","component":"ACTION","schemaVersion":1,"type":"jira.issue.comment","value":{"comment":"Comment from automation: issue type has changed","publicComment":false,"sendNotifications":true,"addCommentOnce":false,"useLegacyRendering":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false}],"projects":[],"labels":[],"tags":[]}],"cloud":false}
  • The rule is triggered twice and the action successfully executed. In the audit log, there are 2 events fired at the same time:
  • The issue was moved from 1 project to the other (in addition to its type being changed during the move), forcing the Jira application to change the issue key, as we can see in the issue history:
  • With the debug packages as per Rule execution trace made easy enabled, we can see that 2 events were fired from the Move operation, and that both event types triggered the rule:
    • The rule was triggered for eventTypeId=2, or the issue updated event. We can use the traceID '85336f75-9bcf-451f-b1fe-ba22da730b10' to follow the execution:

      2024-11-22 17:46:11,164+0100 http-nio-41215-exec-2 url: /j51215/secure/MoveIssueConfirm.jspa; user: admin DEBUG admin 1066x966x1 98jrcd 0:0:0:0:0:0:0:1 /secure/MoveIssueConfirm.jspa [c.c.j.p.automation.event.DefaultEventRuleRegistry] Rule registry executeEventRules init: traceId '85336f75-9bcf-451f-b1fe-ba22da730b10' assigned, 0 sync rules, 1 async rules found for event 'com.atlassian.jira.event.issue.IssueEvent@53fc6b35[issue=SCRUM-27,comment=<null>,worklog=<null>,changelog=[GenericEntity:ChangeGroup][issue,10025][author,JIRAUSER10000][created,2024-11-22 17:46:11.038][id,10028],eventTypeId=2,sendMail=true,params={baseurl=http://localhost:41215/j51215},subtasksUpdated=false,spanningOperation=Optional.empty]'
      ...
      2024-11-22 17:46:11,182+0100 automation-event-serializer:thread-2 DEBUG admin     [c.c.j.p.automation.event.DefaultEventRuleRegistry] Submitting AutomationEvent 'jira:issue_updated:issue_updated' with traceId='85336f75-9bcf-451f-b1fe-ba22da730b10' for asynchronous processing...
      ...
      2024-11-22 17:46:11,403+0100 automation-event-serializer:thread-1 DEBUG admin     [c.c.j.p.automation.event.DefaultEventRuleRegistry] Submitting AutomationEvent 'jira:issue_updated:issue_commented' with traceId='85336f75-9bcf-451f-b1fe-ba22da730b10::814558e8-6eb2-42a3-90ee-591d37f65e53' for asynchronous processing...
      ...
      2024-11-22 17:46:11,451+0100 automation-rule-executor:thread-3 INFO admin     [c.c.a.api.service.SingleRuleExecutorServiceImpl] Rule execution 'issue type changed' (rule ID [1], audit ID [4]) on tenant com.codebarrel.tenant.global and event traceId='85336f75-9bcf-451f-b1fe-ba22da730b10': FINISHED (Took 251ms to run, 370ms end to end) with state SUCCESS
    • The rule was also triggered for eventTypeId=9, or the issue moved event. We can use the traceID '3a315fc2-639f-486c-b520-b4da51a0b941' to follow the execution.

      2024-11-22 17:46:11,162+0100 http-nio-41215-exec-2 url: /j51215/secure/MoveIssueConfirm.jspa; user: admin DEBUG admin 1066x966x1 98jrcd 0:0:0:0:0:0:0:1 /secure/MoveIssueConfirm.jspa [c.c.j.p.automation.event.DefaultEventRuleRegistry] Rule registry executeEventRules init: traceId '3a315fc2-639f-486c-b520-b4da51a0b941' assigned, 0 sync rules, 1 async rules found for event 'com.atlassian.jira.event.issue.IssueEvent@4c56f4b7[issue=SCRUM-27,comment=<null>,worklog=<null>,changelog=[GenericEntity:ChangeGroup][issue,10025][author,JIRAUSER10000][created,2024-11-22 17:46:11.038][id,10028],eventTypeId=9,sendMail=true,params={baseurl=http://localhost:41215/j51215},subtasksUpdated=false,spanningOperation=Optional.empty]'
      ...
      2024-11-22 17:46:11,186+0100 automation-event-serializer:thread-1 DEBUG admin     [c.c.j.p.automation.event.DefaultEventRuleRegistry] Submitting AutomationEvent 'jira:issue_updated:issue_moved' with traceId='3a315fc2-639f-486c-b520-b4da51a0b941' for asynchronous processing...
      ...
      2024-11-22 17:46:11,394+0100 automation-event-serializer:thread-2 DEBUG admin     [c.c.j.p.automation.event.DefaultEventRuleRegistry] Submitting AutomationEvent 'jira:issue_updated:issue_commented' with traceId='3a315fc2-639f-486c-b520-b4da51a0b941::823aa735-5a72-441b-a8e7-2e20613bab35' for asynchronous processing...
      ...
      2024-11-22 17:46:11,424+0100 automation-rule-executor:thread-4 INFO admin     [c.c.a.api.service.SingleRuleExecutorServiceImpl] Rule execution 'issue type changed' (rule ID [1], audit ID [5]) on tenant com.codebarrel.tenant.global and event traceId='3a315fc2-639f-486c-b520-b4da51a0b941': FINISHED (Took 223ms to run, 342ms end to end) with state SUCCESS

原因

When an issue is moved to a new project and a new type, 2 events are fired by the Jira application:

  • the "Issue updated" event, due to the fact that the issue type was changed
  • the "Issue moved" event, due to the fact that the issue was moved to a new project, causing its issue key to be updated to the format <NEW_PROJECT_KEY>-<ISSUE_NUM_IN_THE_PROJECT>.

Each of these 2 events is processed separately by the rule hence, the rule is executed twice and we see 2 entries in the audit log.

ソリューション

There are different solutions depending on the trigger and action that are configured.

The example rule shown in the diagnosis section (using the "Comment on issue" action), we can tick the Prevent duplicates by only adding this comment once to a particular issue option on the Comment on issue action.

Alternatively, we can limit the operations the trigger will execute for. The trigger used in this example rule, Field value changed, can be executed for Create issue, Edit issue, Transition issue and Assign issue. You can limit the operations to only Edit issue if it's applicable.


最終更新日 2024 年 11 月 26 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.