スプリントに対して課題の追加または削除が行われたときに通知を送信する

プラットフォームについて: Cloud と Data Center - この記事は クラウド プラットフォームとデータセンター プラットフォームの両方に等しく当てはまります。

Server* 製品のサポートは 2024 年 2 月 15 日に終了しました。Server 製品を実行している場合は、 アトラシアン Server サポート終了 のお知らせにアクセスして、移行オプションを確認してください。

*Fisheye および Crucible は除く

要約

この記事では、アクティブ スプリントに対して課題の追加または削除が行われたときにメールを送信する Automation for Jira (A4J) ルールについて説明します。このソリューションは、Jira Cloud と Data Center / Server バージョン (A4J 9.0.3 以降を実行) の両方で動作します。記事の最後には、Cloud バージョンと Data Center バージョンでエクスポートされたルールとデモ動画の例があります。

注: パラレル スプリント機能が無効です (これはパラレル スプリントを有効にした状態でテストされておらず、この機能を有効にしても動作しない可能性があります)

カスタマイズされたソリューション

このページの内容は、Jira でのカスタマイズに関連しています。カスタマイズは アトラシアン サポート オファリング に含まれていないため、アトラシアン サポートは、このページ に記載されている手順に対するサポートの提供を保証できません 。この資料は情報提供のみを目的としているため、自己責任で使用されるようご注意ください。

また、ファイルの直接変更によるカスタマイズはアップグレード プロセスに含まれない点にご注意ください。 このような変更は、アップグレード後のインスタンスで手動で再適用する必要があります。

これはカスタマイズでありサポート対象外のため、この記事で提供されている解決策が常に機能するとは限らない、またはインスタンスで一貫性がない可能性があることに注意してください。 リスト フィールドの自動化において、変更ログに必ずしも正確な情報が表示されない既知の問題があり、このソリューションの機能に影響する可能性があります。

ソリューション

実装

前提

a. 1 つのルールでトリガーできるスプリントの変更は 1 つだけです。b. UI と REST API では、課題の更新ごとに 1 つのスプリントしか変更できません。c. 課題のスプリント フィールドには、複数のクローズド (完了) スプリントと (ゼロまたは 1 つのアクティブなまたは将来の) スプリントを含めることができます。

スプリントが変更されると、A4J のスマート値 FieldChange は次のようになります。

  • "{{fieldChange.from}}" = 課題の以前のスプリント ID

  • "{{fieldChange.to}}" = 課題の現在のスプリント ID

方法

このソリューションは次のものを使用します。

  • Jira Agile REST API コール (Web リクエスト) を使用してスプリントの状態を取得し、それを条件に使用して通知を送信するかどうかを決定します。

  • 課題の「{{fieldChange.to}}」と「{{fieldChange.from}}」の文字列。課題が別のスプリントに移動または追加されたことを示すコンマで区切られたスプリント ID を含む

  • 集合理論と基本的な数学 - 基本的な数学とスマート値リスト関数を使って、基本的な集合の和集合と交叉を求めて、「変更された」スプリントを検索します。

最も難しいユースケース

  • 送信元: closed-sprint-1、active-sprint、closed-sprint-2

  • 宛先: closed-sprint-1、closed-sprint-2、future-sprint

スプリント ID の fieldChange はソートされているので、「変更された」スプリントは「送信元」または「宛先」リストの ID のリストの中央にある可能性があります。A4J DC バージョンにはループ (高度な分岐) があります。

ルールの手順概要

1) 「0」というスプリント ID アンカーを使用してリストを生成します - A4J は空のリストを理解するため、これが必要です - 空のリストは null に設定されます。したがって、リストには少なくとも 1 つの要素が必要です

fromList = "0" + "{{fieldChange.to}} toList = "0" + "{{fieldChange.to}}

2) リストの和集合を作成します - リストをマージして個別スプリント ID のセットを生成します。mergedList = distinct(fromtList + toList)

3) 課題に対して削除または追加されたスプリントを探してください。前提は、課題の更新ごとに 1 つの変更しかできないということです。これは、現在の UI と REST API にも当てはまります。課題の更新ごとに追加または削除できるのは、未完了スプリント 1 つだけです。また、課題に含まれる未完了スプリント (オープンなまたは将来の) が最大で 1 つのみです。

removedSprintId = mergedList - toList newSprintId = mergedList - fromList

4) スプリントが追加されたことを通知します

  • newSprintId が null でない場合は、

  • newSprint = HTTP GET /agile/1.0/sprint/<newSprintId>

  • newSprint.state が「アクティブ」である場合は、

  • 課題がスプリントに追加されたことを通知します

5) スプリントが削除されたことを通知します

  • removedSprintId が null でない場合は

  • removedSprint = HTTP GET /agile/1.0/sprint/<removedSprintId>

  • removedSprint.state がアクティブな場合は

  • 課題がスプリントから削除されたことを通知します

IF-THEN-ELSE の代わりに 2 つの IF ステートメントを使用します。その理由は、変更されたスプリントがアクティブなのか、それとも将来のものなのかは、REST API を呼び出して情報を調べるまでわからないからです。REST API の呼び出しのみを最小限に抑えようとしています。

また、REST API 呼び出しを行うタイミングも重要です。[この Webhook からの応答を受信するまで、後続のルール アクションの実行を遅延します] オプションのチェックボックスをオンにして、ルールを引き続き実行する前にスプリント オブジェクトがあることを確認します。それ以外の場合は、スプリント オブジェクトが null になるため、後続のロジックが失敗します。

スプリント REST API

単一スプリントの情報を取得するための REST API は、GET /rest/agile/1.0/sprint/{sprintId} です。

Web リクエストをセットアップする

手順はナレッジ ベース記事「REST API 呼び出しで Automation for Jira を拡張する方法」をご確認ください。

次が必要です。

REST API の応答を待つ必要があります。

応答を受け取るまで、次のルール アクションの実行を遅らせる

REST API レスポンス データへのアクセス

Web リクエストが成功すると、スマート値「{{webHookResponse.body}}」に 1 つのスプリント レコードが格納されます。次の例は、ID = 4 のスプリント レコードを返す REST API 呼び出しによるものです。

1 2 3 4 5 6 7 8 9 10 11 12 curl -s -u scrummaster:mypassword -X GET "http://localhost:42010/j82010/rest/agile/1.0/sprint/4" | python3 -mjson.tool { "id": 4, "self": "http://localhost:42010/j82010/rest/agile/1.0/sprint/4", "state": "active", "name": "ActiveSprint", "startDate": "2023-12-01T19:33:00.000-08:00", "endDate": "2023-12-31T19:33:00.000-08:00", "activatedDate": "2023-12-06T19:45:01.005-08:00", "originBoardId": 8, "goal": "Dec-2023 " }

スプリント データ フィールドには、次のスマート値を使用してアクセスできます。

1 2 3 4 5 6 7 8 9 {{webhookResponse.body.id}} {{webhookResponse.body.self}} {{webhookResponse.body.state}} {{webhookResponse.body.name}} {{webhookResponse.body.startDate}} {{webhookResponse.body.endDate}} {{webhookResponse.body.activatedDate}} {{webhookResponse.body.originBoardId}} {{webhookResponse.body.goal}}

自動化ルール

スプリントに対して課題の追加または削除が行われたときに通知を送信する自動化
スプリントに対して課題の追加または削除が行われたときに通知を送信する自動化
スプリントに対して課題の追加または削除が行われたときに通知を送信する自動化

Jira Cloud と Jira Data Center の例は基本的に同じです。主なルールの実装は同じです。UI は異なり、エクスポートされたルールには互換性がありません。したがって、エクスポートされたルールの例は 2 セット必要になります。どちらの例でも、Jira への Web リクエスト コールを行うルールでの認証に API トークンを使用しています。通知の実装では、無料の Web サーバーを提供する公開サイト「webhook.site」への Web リクエストを使用しています。通知は、メール、Slack、または同じスマート値を使用する他の Web サイトに変更できます。

Data Center バージョン

エクスポートされたルールの例では、通知用の Web リクエスト アクションとローカルホスト上の Jira サイトを使用しています。これをご自身の環境に実装するには、以下の手順を行います。

  • 組織の環境に合わせて通知コンポーネントを変更します。たとえば、メール、Slack、ルール監査ログのログ アクションに変更します。

  • REST API を介してスプリント情報を取得する Web リクエストを、正しいベース URL とベアラー トークンを使用して、ご自身の Jira インスタンスに変更します。

    • アクティブ スプリント JSON に対して課題の追加または削除を行う自動化ルール

      1 {"rules":[{"id":39,"clientKey":"com.codebarrel.tenant.global","name":"Issue Added/Removed from Active Sprint (v4)","state":"ENABLED","description":"Send a notification when an issue is added or removed from an active sprint.\n\nPremise\na. This has not been tested with parallel sprints enabled\nb. There can be only one sprint change per rule triggered. \nc. The UI and REST API allow only one sprint change per issue update.\nd. Tested using Jira 8.20.10 and A4J 9.0.3 with limited scenarios\ne. An issue's sprint field can have multiple closed (completed) and (zero or one active or future) sprints.\n\n\nScenario:\n\nSprints ID. state\n----------------+---------------\n1 completed\n3 future\n4 active\n5 completed \n\n1. simple active\n EMPTY -> 4 >>> send notification that issue has been added to 4\n 4. -> EMPTY >>> send notification that issue has been removed from 4\n\n2. simple active,closed\n\n 1 -> 1,4 >>> send notification that issue has been added to 4\n 1,4 -> 1 >>> send notification that issue has been removed from 4\n\n3. simple active, 2x closed\n\n 1,5 -> 1,4,5 >>> send notification that issue has been added to 4\n 1,4,5 -> 1,5 >>> send notification that issue has been removed from 4\n\n4. simple future (no notifications)\n\n EMPTY -> 3 >>> no notification \n 3 -> EMPTY >>> no notification \n\n5. simple future,closed\n\n 1 -> 1,3 >>> no notification\n 1,3 -> 1 >>> no notification\n\n6. simple future, 2x closed\n\n 1,5 -> 1,3,5 >>> no notification\n 1,3,5 -> 1,5 >>> no notification\n\n7. move between future and active:\n 1,3 -> 1,4 >>> send notification that issue has been added to 4\n 1,4 -> 1,3 >>> send notification that issue has been removed from 4\n 1,3,5 -> 1,4,5 >>> send notification that issue has been added to 4\n 1,4,5 -> 1,3,5 >>> send notification that issue has been removed from 4\n\n-----------------------------------\n\nCan add these to check my variable values in a notification action prior the main IF block:\n\nTEST My variables\n\nissue.key = {{issue.key}}\nfieldChange {{fieldChange}}\n===============\nanchor = {{anchor}}\nfrom.List = {{fromList}}\nfromListSize = {{fromListSize}}\nfromListSum = {{fromListSum}}\ntoList = {{toList}} \ntoListSize={{toListSize}}\ntoListSum = {{toListSum}}\n-------\nmergedSprintsString = {{mergedSprintsString}}\nmergedSprintsList = {{{{mergedSprintsString.split(',').distinct}}\nmergedListSprintsSum = {{mergedSprintsListSum}}\npreviousSprintID = {{previousSprintID}}\ncurrentSprintID = {{currentSprintID}}\n--------\ncheckAdd = {{checkAdd}}. \ncheckRemove = {{checkRemove}}\n\n-------------------------\n\nif checkAdd >= 0 {\n if new sprint is active {\n send notification\n }\n}\n\nif checkRemove >= 0 {\n if new sprint is active {\n send notification\n }\n}\n\n-----------------------------------\n\nselect \"ID\", \"NAME\", \"STARTED\", \"CLOSED\" from \"AO_60DB71_SPRINT\" order by \"ID\";\n ID | NAME | STARTED | CLOSED \n----+--------------------------+---------+--------\n 1 | Nov-2023 | t | t\n 2 | Sample Sprint 1 | t | t\n 3 | FutureSprint | f | f\n 4 | ActiveSprint | t | f\n 5 | short sprint Dec 11 only | t | t\n(5 rows)\n\nclosed sprint = STARTED && CLOSED\nopen sprint = STARTED && !CLOSED\nfuture sprint = !STARTED && !CLOSED\n\n---------------\n\n% curl -s -u username:password -X GET \"http://localhost:42010/j82010/rest/api/latest/issue/SP-32\" | python3 -mjson.tool | grep -B1 \"com.atlassian.greenhopper.service.sprint.Sprint\"\n\n\"customfield_10106\": [ \n\n\"com.atlassian.greenhopper.service.sprint.Sprint@3478edbe[id=1,rapidViewId=1,state=CLOSED,name=Nov-2023,startDate=2023-11-01T01:18:00.000-07:00,endDate=2023-11-30T01:38:00.000-08:00,completeDate=2023-12-08T14:36:44.069-08:00,activatedDate=2023-02-03T01:18:22.593-08:00,sequence=1,goal=<null>,autoStartStop=false]\", \n\n\"com.atlassian.greenhopper.service.sprint.Sprint@5255fc4c[id=4,rapidViewId=8,state=ACTIVE,name=ActiveSprint,startDate=2023-12-01T19:33:00.000-08:00,endDate=2023-12-31T19:33:00.000-08:00,completeDate=<null>,activatedDate=2023-12-06T19:45:01.005-08:00,sequence=4,goal=Dec-2023 ,autoStartStop=false]\", \n\n\"com.atlassian.greenhopper.service.sprint.Sprint@68447f13[id=5,rapidViewId=8,state=CLOSED,name=short sprint Dec 11 only,startDate=2023-12-11T03:48:00.000-08:00,endDate=2023-12-11T16:00:00.000-08:00,completeDate=2023-12-11T16:00:05.489-08:00,activatedDate=2023-12-11T15:56:42.006-08:00,sequence=5,goal=,autoStartStop=false]\"","canOtherRuleTrigger":false,"notifyOnError":"NEVER","authorAccountId":"JIRAUSER10000","actorAccountId":"JIRAUSER10000","created":1702487161767,"updated":1702490122370,"trigger":{"id":"5563","component":"TRIGGER","schemaVersion":2,"type":"jira.issue.field.changed","value":{"synchronous":false,"fields":[{"value":"customfield_10106","type":"field"}],"actions":[]},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},"components":[{"id":"5564","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702452982311","name":{"type":"FREE","value":"anchor"},"type":"SMART","query":{"type":"SMART","value":"0,"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5565","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702449582115","name":{"type":"FREE","value":"fromList"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.from).split(',')}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5566","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702465879402","name":{"type":"FREE","value":"fromListSize"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{anchor.concat(fieldChange.from).split(',').size}}{{/}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5567","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702372354065","name":{"type":"FREE","value":"fromListSum"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.from).split(',').sum.floor}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5568","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702449665257","name":{"type":"FREE","value":"toList"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.to).split(',')}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5569","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702465911403","name":{"type":"FREE","value":"toListSize"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{anchor.concat(fieldChange.to).split(',').size}}{{/}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5570","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702372391432","name":{"type":"FREE","value":"toListSum"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.to).split(',').sum.floor}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5571","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702434584284","name":{"type":"FREE","value":"mergedSprintsString"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.from).concat(\",\").concat(anchor.concat(fieldChange.to)).remove(\" \")}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5572","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702442284171","name":{"type":"FREE","value":"mergedSprintsListSum"},"type":"SMART","query":{"type":"SMART","value":"{{mergedSprintsString.split(',').distinct.sum}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5573","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702455209130","name":{"type":"FREE","value":"previousSprintID"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{mergedSprintsListSum}}-{{toListSum}}{{/}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5574","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702455348543","name":{"type":"FREE","value":"currentSprintID"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{mergedSprintsListSum}}-{{fromListSum}}{{/}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5575","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702463652061","name":{"type":"FREE","value":"checkAdd"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{toListSize}}-{{fromListSize}}{{/}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5576","component":"ACTION","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702463716250","name":{"type":"FREE","value":"checkRemove"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{fromListSize}}-{{toListSize}}{{/}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5577","component":"ACTION","schemaVersion":2,"type":"jira.issue.outgoing.webhook","value":{"url":"https://webhook.site/87d69382-8c6e-4877-8056-0297c8089e88","headers":[{"id":"_header_1702288366811","name":"","value":{"keyOrValue":"","secret":false}}],"sendIssue":false,"contentType":"custom","customBody":"TEST My variables\n\nissue.key = {{issue.key}}\nfieldChange {{fieldChange}}\n===============\nanchor = {{anchor}}\nfrom.List = {{fromList}}\nfromListSize = {{fromListSize}}\nfromListSum = {{fromListSum}}\ntoList = {{toList}} \ntoListSize={{toListSize}}\ntoListSum = {{toListSum}}\n-------\nmergedSprintsString = {{mergedSprintsString}}\nmergedSprintsList = {{mergedSprintsString.split(',').distinct}}\nmergedListSprintsSum = {{mergedSprintsListSum}}\npreviousSprintID = {{previousSprintID}}\ncurrentSprintID = {{currentSprintID}}\n--------\ncheckAdd = {{checkAdd}}. \ncheckRemove = {{checkRemove}}\n\n-------------------------\nNotes:\n\nif checkAdd >= 0 {\n if new sprint is active {\n send notification\n }\n}\n\nif checkRemove >= 0 {\n if new sprint is active {\n send notification\n }\n}\n\n","method":"POST","responseEnabled":false,"usedSecretsKeys":[]},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5578","component":"BRANCH","schemaVersion":1,"type":"jira.issue.related","value":{"relatedType":"current","jql":"","linkTypes":[],"onlyUpdatedIssues":false,"processIssuesInBulk":false},"children":[{"id":"5579","component":"CONDITION","parentId":"5578","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{checkAdd}}","second":"-1","operator":"GREATER_THAN"},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5580","component":"ACTION","parentId":"5578","schemaVersion":2,"type":"jira.issue.outgoing.webhook","value":{"url":"http://localhost:42010/j82010/rest/agile/1.0/sprint/{{currentSprintID}}","headers":[{"id":"_header_1701949243211","name":"Authorization","value":{"keyOrValue":"Bearer MTE0NTk5MjM5MTM1Ohg2tih+m5cX3gW0IGMh+sFxp0Hc","secret":false}}],"sendIssue":false,"contentType":"empty","method":"GET","responseEnabled":true,"usedSecretsKeys":[]},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5581","component":"ACTION","parentId":"5578","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702251014615","name":{"type":"FREE","value":"currentSprintState"},"type":"SMART","query":{"type":"SMART","value":"{{webhookResponse.body.state}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5582","component":"CONDITION","parentId":"5578","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{currentSprintState}}","second":"active","operator":"EQUALS"},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5583","component":"ACTION","parentId":"5578","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702469748807","name":{"type":"FREE","value":"sprintName"},"type":"SMART","query":{"type":"SMART","value":"{{webhookResponse.body.name}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5584","component":"ACTION","parentId":"5578","schemaVersion":2,"type":"jira.issue.outgoing.webhook","value":{"url":"https://webhook.site/87d69382-8c6e-4877-8056-0297c8089e88","headers":[{"id":"_header_1701917180984","name":"Authorization","value":{"keyOrValue":"Bearer x","secret":false}}],"sendIssue":false,"contentType":"custom","customBody":"{{now .convertToTimeZone(\"America/Los_Angeles\").longDateTime}}:\nAdded {{issue.key}} to active sprint '{{sprintName}}'\n\nOld Issue Sprint: '[{{fieldChange.fromString}}]'\nNew Issue Sprint: '[{{fieldChange.toString}}]'\n","method":"POST","responseEnabled":false,"usedSecretsKeys":[]},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false}],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5585","component":"CONDITION","schemaVersion":1,"type":"jira.condition.container.block","children":[{"id":"5586","component":"CONDITION_BLOCK","parentId":"5585","schemaVersion":1,"type":"jira.condition.if.block","value":{"conditionMatchType":"ALL"},"children":[{"id":"5588","component":"ACTION","parentId":"5586","schemaVersion":2,"type":"jira.issue.outgoing.webhook","value":{"url":"http://localhost:42010/j82010/rest/agile/1.0/sprint/{{previousSprintID}}","headers":[{"id":"_header_1701946642254","name":"Authorization","value":{"keyOrValue":"Bearer MTE0NTk5MjM5MTM1Ohg2tih+m5cX3gW0IGMh+sFxp0Hc","secret":false}}],"sendIssue":false,"contentType":"empty","method":"GET","responseEnabled":true,"usedSecretsKeys":[]},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5589","component":"ACTION","parentId":"5586","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1701947930023","name":{"type":"FREE","value":"previousSprintState"},"type":"SMART","query":{"type":"SMART","value":"{{webhookResponse.body.state}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5590","component":"CONDITION","parentId":"5586","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{previousSprintState}}","second":"active","operator":"EQUALS"},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5591","component":"ACTION","parentId":"5586","schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702469652306","name":{"type":"FREE","value":"sprintName"},"type":"SMART","query":{"type":"SMART","value":"{{webhookResponse.body.name}}"},"lazy":false},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false},{"id":"5592","component":"ACTION","parentId":"5586","schemaVersion":2,"type":"jira.issue.outgoing.webhook","value":{"url":"https://webhook.site/87d69382-8c6e-4877-8056-0297c8089e88","headers":[{"id":"_header_1701912785834","name":"","value":{"keyOrValue":"","secret":false}}],"sendIssue":false,"contentType":"custom","customBody":"{{now.convertToTimeZone(\"America/Los_Angeles\").longDateTime}}:\nRemoved issue {{issue.key}} from active sprint '{{sprintName}}'\n\nIssue Sprint: '[{{issue.sprint}}]'\nfieldChange.to : '{{fieldChange.toString}}'\nfieldChange.from : '{{fieldChange.fromString}}'\nprevious sprint state: '{{previousSprintState}}'","method":"POST","responseEnabled":false,"usedSecretsKeys":[]},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false}],"conditions":[{"id":"5587","component":"CONDITION","conditionParentId":"5586","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{checkRemove}}","second":"-1","operator":"GREATER_THAN"},"children":[],"conditions":[],"optimisedIds":[],"newComponent":false}],"optimisedIds":[],"newComponent":false}],"conditions":[],"optimisedIds":[],"newComponent":false}],"projects":[],"labels":[],"tags":[]}],"cloud":false}

Cloud バージョン

エクスポートされたルールの例では、通知用の Web リクエスト アクションとローカルホスト上の Jira サイトを使用しています。これをご自身の環境に実装するには、以下の手順を行います。

  • 組織の環境に合わせて通知コンポーネントを変更します。たとえば、メール、Slack、ルール監査ログのログ アクションに変更します。

  • REST API を介してスプリント情報を取得する Web リクエストを、正しいベース URL と基本認証トークンを使用して、ご自身の Jira インスタンスに変更します。Jira Cloud の基本認証用のトークンを作成する方法についての記事をご覧ください

  • スプリント JSON に対して課題の追加または削除が行われたときに通知を送信する自動化ルール:

    1 {"cloud":true,"rules":[{"id":17203407,"clientKey":"a34b2254-4bdb-3129-80ae-4969d95c3851","name":"Issue Added/Removed from Active Sprint (Cloud)","state":"ENABLED","description":"Send a notification when an issue is added or removed from an active sprint.\n\nPremise\na. This has not been tested with parallel sprints enabled\nb. There can be only one sprint change per rule triggered. \nc. The UI and REST API allow only one sprint change per issue update.\nd. Tested using Jira 8.20.10 and A4J 9.0.3 with limited scenarios\ne. An issue's sprint field can have multiple closed (completed) and (zero or one active or future) sprints.\n\n\nScenario:\n\nSprints ID. state\n----------------+---------------\n1 completed\n3 future\n4 active\n5 completed \n\n1. simple active\n EMPTY -> 4 >>> send notification that issue has been added to 4\n 4. -> EMPTY >>> send notification that issue has been removed from 4\n\n2. simple active,closed\n\n 1 -> 1,4 >>> send notification that issue has been added to 4\n 1,4 -> 1 >>> send notification that issue has been removed from 4\n\n3. simple active, 2x closed\n\n 1,5 -> 1,4,5 >>> send notification that issue has been added to 4\n 1,4,5 -> 1,5 >>> send notification that issue has been removed from 4\n\n4. simple future (no notifications)\n\n EMPTY -> 3 >>> no notification \n 3 -> EMPTY >>> no notification \n\n5. simple future,closed\n\n 1 -> 1,3 >>> no notification\n 1,3 -> 1 >>> no notification\n\n6. simple future, 2x closed\n\n 1,5 -> 1,3,5 >>> no notification\n 1,3,5 -> 1,5 >>> no notification\n\n7. move between future and active:\n 1,3 -> 1,4 >>> send notification that issue has been added to 4\n 1,4 -> 1,3 >>> send notification that issue has been removed from 4\n 1,3,5 -> 1,4,5 >>> send notification that issue has been added to 4\n 1,4,5 -> 1,3,5 >>> send notification that issue has been removed from 4\n\n-----------------------------------\n\nCan add these to check my variable values in a notification action prior to the main IF block:\n\nTEST My variables\n\nissue.key = {{issue.key}}\nfieldChange {{fieldChange}}\n===============\nanchor = {{anchor}}\nfrom.List = {{fromList}}\nfromListSize = {{fromListSize}}\nfromListSum = {{fromListSum}}\ntoList = {{toList}} \ntoListSize={{toListSize}}\ntoListSum = {{toListSum}}\n-------\nmergedSprintsString = {{mergedSprintsString}}\nmergedSprintsList = {{{{mergedSprintsString.split(',').distinct}}\nmergedListSprintsSum = {{mergedSprintsListSum}}\npreviousSprintID = {{previousSprintID}}\ncurrentSprintID = {{currentSprintID}}\n--------\ncheckAdd = {{checkAdd}}. \ncheckRemove = {{checkRemove}}\n\n-------------------------\n\nif checkAdd >= 0 {\n if new sprint is active {\n send notification\n }\n}\n\nif checkRemove >= 0 {\n if new sprint is active {\n send notification\n }\n}\n\n-----------------------------------\n\nSample Data (from test Data Center environment):\n\nselect \"ID\", \"NAME\", \"STARTED\", \"CLOSED\" from \"AO_60DB71_SPRINT\" order by \"ID\";\n ID | NAME | STARTED | CLOSED \n----+--------------------------+---------+--------\n 1 | Nov-2023 | t | t\n 2 | Sample Sprint 1 | t | t\n 3 | FutureSprint | f | f\n 4 | ActiveSprint | t | f\n 5 | short sprint Dec 11 only | t | t\n(5 rows)\n\nclosed sprint = STARTED && CLOSED\nopen sprint = STARTED && !CLOSED\nfuture sprint = !STARTED && !CLOSED\n\n---------------\n\n% curl -s -u username:password -X GET \"http://localhost:42010/j82010/rest/api/latest/issue/SP-32\" | python3 -mjson.tool | grep -B1 \"com.atlassian.greenhopper.service.sprint.Sprint\"\n\n\"customfield_10106\": [ \n\n\"com.atlassian.greenhopper.service.sprint.Sprint@3478edbe[id=1,rapidViewId=1,state=CLOSED,name=Nov-2023,startDate=2023-11-01T01:18:00.000-07:00,endDate=2023-11-30T01:38:00.000-08:00,completeDate=2023-12-08T14:36:44.069-08:00,activatedDate=2023-02-03T01:18:22.593-08:00,sequence=1,goal=<null>,autoStartStop=false]\", \n\n\"com.atlassian.greenhopper.service.sprint.Sprint@5255fc4c[id=4,rapidViewId=8,state=ACTIVE,name=ActiveSprint,startDate=2023-12-01T19:33:00.000-08:00,endDate=2023-12-31T19:33:00.000-08:00,completeDate=<null>,activatedDate=2023-12-06T19:45:01.005-08:00,sequence=4,goal=Dec-2023 ,autoStartStop=false]\", \n\n\"com.atlassian.greenhopper.service.sprint.Sprint@68447f13[id=5,rapidViewId=8,state=CLOSED,name=short sprint Dec 11 only,startDate=2023-12-11T03:48:00.000-08:00,endDate=2023-12-11T16:00:00.000-08:00,completeDate=2023-12-11T16:00:05.489-08:00,activatedDate=2023-12-11T15:56:42.006-08:00,sequence=5,goal=,autoStartStop=false]\"","authorAccountId":"5cdee6194326200dc9723dce","actor":{"type":"ACCOUNT_ID","value":"557058:f58131cb-b67d-43c7-b30d-6b58d40bd077"},"created":1704521545541,"updated":1704535957606,"trigger":{"id":"379623838","component":"TRIGGER","parentId":null,"conditionParentId":null,"schemaVersion":2,"type":"jira.issue.field.changed","value":{"changeType":"ANY_CHANGE","fields":[{"value":"Sprint","type":"fieldName"}],"actions":[]},"children":[],"conditions":[],"connectionId":null},"components":[{"id":"379623839","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702452982311","name":{"type":"FREE","value":"anchor"},"type":"SMART","query":{"type":"SMART","value":"0,"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623840","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702449582115","name":{"type":"FREE","value":"fromList"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.from).split(',')}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623841","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702465879402","name":{"type":"FREE","value":"fromListSize"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{anchor.concat(fieldChange.from).split(',').size}}{{/}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623842","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702372354065","name":{"type":"FREE","value":"fromListSum"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.from).split(',').sum.floor}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623843","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702449665257","name":{"type":"FREE","value":"toList"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.to).split(',')}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623844","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702465911403","name":{"type":"FREE","value":"toListSize"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{anchor.concat(fieldChange.to).split(',').size}}{{/}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623845","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702372391432","name":{"type":"FREE","value":"toListSum"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.to).split(',').sum.floor}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623846","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702434584284","name":{"type":"FREE","value":"mergedSprintsString"},"type":"SMART","query":{"type":"SMART","value":"{{anchor.concat(fieldChange.from).concat(\",\").concat(anchor.concat(fieldChange.to)).remove(\" \")}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623847","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702442284171","name":{"type":"FREE","value":"mergedSprintsListSum"},"type":"SMART","query":{"type":"SMART","value":"{{mergedSprintsString.split(',').distinct.sum}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623848","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702455209130","name":{"type":"FREE","value":"previousSprintID"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{mergedSprintsListSum}}-{{toListSum}}{{/}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623849","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702455348543","name":{"type":"FREE","value":"currentSprintID"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{mergedSprintsListSum}}-{{fromListSum}}{{/}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623850","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702463652061","name":{"type":"FREE","value":"checkAdd"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{toListSize}}-{{fromListSize}}{{/}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623851","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702463716250","name":{"type":"FREE","value":"checkRemove"},"type":"SMART","query":{"type":"SMART","value":"{{#=}}{{fromListSize}}-{{toListSize}}{{/}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623852","component":"BRANCH","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.issue.related","value":{"relatedType":"current","jql":"","linkTypes":[],"onlyUpdatedIssues":false,"similarityLimit":40,"compareValue":0},"children":[{"id":"379623853","component":"CONDITION","parentId":"379623852","conditionParentId":null,"schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{checkAdd}}","second":"-1","operator":"GREATER_THAN"},"children":[],"conditions":[],"connectionId":null},{"id":"379623854","component":"ACTION","parentId":"379623852","conditionParentId":null,"schemaVersion":1,"type":"jira.issue.outgoing.webhook","value":{"url":"https://jhnnym.atlassian.net/rest/agile/1.0/sprint/{{currentSprintID}}","headers":[{"id":"_header_1704525058207","name":"Authorization","value":"**************************","headerSecure":true}],"sendIssue":false,"contentType":"empty","customBody":null,"method":"GET","responseEnabled":true,"continueOnErrorEnabled":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623855","component":"ACTION","parentId":"379623852","conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702251014615","name":{"type":"FREE","value":"currentSprintState"},"type":"SMART","query":{"type":"SMART","value":"{{webhookResponse.body.state}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623856","component":"CONDITION","parentId":"379623852","conditionParentId":null,"schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{currentSprintState}}","second":"active","operator":"EQUALS"},"children":[],"conditions":[],"connectionId":null},{"id":"379623857","component":"ACTION","parentId":"379623852","conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702469748807","name":{"type":"FREE","value":"sprintName"},"type":"SMART","query":{"type":"SMART","value":"{{webhookResponse.body.name}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623858","component":"ACTION","parentId":"379623852","conditionParentId":null,"schemaVersion":1,"type":"jira.issue.outgoing.webhook","value":{"url":"https://webhook.site/c1df6916-2311-4fd6-a2e9-67cf3332aebe","headers":[{"id":"_header_1704535785066","name":"","value":"","headerSecure":false}],"sendIssue":false,"contentType":"custom","customBody":"{{now .convertToTimeZone(\"America/Los_Angeles\").longDateTime}}:\nAdded {{issue.key}} to active sprint '{{sprintName}}'\n\nOld Issue Sprint: '[{{fieldChange.fromString}}]'\nNew Issue Sprint: '[{{fieldChange.toString}}]'\n","method":"POST","responseEnabled":false,"continueOnErrorEnabled":false},"children":[],"conditions":[],"connectionId":null}],"conditions":[],"connectionId":null},{"id":"379623859","component":"CONDITION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.condition.container.block","value":null,"children":[{"id":"379623860","component":"CONDITION_BLOCK","parentId":"379623859","conditionParentId":null,"schemaVersion":1,"type":"jira.condition.if.block","value":{"conditionMatchType":"ALL"},"children":[{"id":"379623862","component":"ACTION","parentId":"379623860","conditionParentId":null,"schemaVersion":1,"type":"jira.issue.outgoing.webhook","value":{"url":"https://jhnnym.atlassian.net/rest/agile/1.0/sprint/{{previousSprintID}}","headers":[{"id":"_header_1704529322839","name":"Authorization","value":"**************************","headerSecure":true}],"sendIssue":false,"contentType":"empty","customBody":null,"method":"GET","responseEnabled":true,"continueOnErrorEnabled":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623863","component":"ACTION","parentId":"379623860","conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1701947930023","name":{"type":"FREE","value":"previousSprintState"},"type":"SMART","query":{"type":"SMART","value":"{{webhookResponse.body.state}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623864","component":"CONDITION","parentId":"379623860","conditionParentId":null,"schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{previousSprintState}}","second":"active","operator":"EQUALS"},"children":[],"conditions":[],"connectionId":null},{"id":"379623865","component":"ACTION","parentId":"379623860","conditionParentId":null,"schemaVersion":1,"type":"jira.create.variable","value":{"id":"_customsmartvalue_id_1702469652306","name":{"type":"FREE","value":"sprintName"},"type":"SMART","query":{"type":"SMART","value":"{{webhookResponse.body.name}}"},"lazy":false},"children":[],"conditions":[],"connectionId":null},{"id":"379623866","component":"ACTION","parentId":"379623860","conditionParentId":null,"schemaVersion":1,"type":"jira.issue.outgoing.webhook","value":{"url":"https://webhook.site/c1df6916-2311-4fd6-a2e9-67cf3332aebe","headers":[{"id":"_header_1704535837538","name":"","value":"","headerSecure":false}],"sendIssue":false,"contentType":"custom","customBody":"{{now.convertToTimeZone(\"America/Los_Angeles\").longDateTime}}:\nRemoved issue {{issue.key}} from active sprint '{{sprintName}}'\n\nIssue Sprint: '[{{issue.sprint}}]'\nprevious sprint state: '{{previousSprintState}}'\n\nfieldChange.from : '{{fieldChange.fromString}}'\nfieldChange.to : '{{fieldChange.toString}}'\n","method":"POST","responseEnabled":false,"continueOnErrorEnabled":false},"children":[],"conditions":[],"connectionId":null}],"conditions":[{"id":"379623861","component":"CONDITION","parentId":null,"conditionParentId":"379623860","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{checkRemove}}","second":"-1","operator":"GREATER_THAN"},"children":[],"conditions":[],"connectionId":null}],"connectionId":null}],"conditions":[],"connectionId":null}],"canOtherRuleTrigger":false,"notifyOnError":"NEVER","projects":[],"labels":[],"tags":[{"id":54020255,"tagType":"IS_RULE_UPDATED","tagValue":"true"}],"ruleScope":{"resources":["ari:cloud:jira::site/d09e9e5a-a9d2-4a40-aa41-bd39061e4d35"]},"ruleHome":{"ruleLifecycleHome":{"locationARI":"ari:cloud:jira-software::site/d09e9e5a-a9d2-4a40-aa41-bd39061e4d35"},"ruleBillingHome":{"locationARI":"ari:cloud:jira-software::site/d09e9e5a-a9d2-4a40-aa41-bd39061e4d35"}},"writeAccessType":"UNRESTRICTED","collaborators":[],"billingType":"NORMAL"}]}

更新日時: 2024年8月18日

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。