Creating and linking an Asset object using Automation for Jira via REST API

お困りですか?

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

コミュニティに質問

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

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

*Fisheye および Crucible は除く

目的

  • Currently, the integration between Automation for Jira and Assets objects is limited in the Jira Data Center, it's not possible to use Actions to create Assets objects: JIRAAUTOSERVER-869 - Getting issue details... STATUS JIRAAUTOSERVER-464 - Getting issue details... STATUS

要件 

  • Automation For Jira
  • Assets plugin
  • An Assets custom field configured for linking the object with the Jira issue - Default Assets custom field

ソリューション

This documentation described how to use Automation for Jira (bundled with Jira 9.0+) to create and link Assets objects in Jira issues using REST API from Assets: Assets REST API documentation

ステップ

1.

Create a trigger: In this example, "Field value changed" is used to monitor the "Labels" field for "All issue operations", but other triggers can be used depending on your needs: 

2. 

Create an Issue fields condition: In order to trigger the automation, create an "Issue Fields Condition". For example, execute the automation for all Jira issues with the "assets_create_object" added:

3. 

Create a Send web request action: To create an object in Assets, we'll use the "Send Web Request" action to perform a POST in the create object REST API:

  1. Webhook URL: 

    <JIRA_BASEURL>/rest/assets/1.0/object/create
  2. Headers: For creating the <TOKEN> use: Using Personal Access Tokens

    ヘッダー
    Content-Typeapplication/json
    認証Bearer <TOKEN>
  3. HTTP method: POST
  4. Webhook body: Custom data
  5. Wait for response:  Delay execution of subsequent rule actions until we've received a response for this webhook
  6. Custom data: We will use this field as a payload for custom fields that will be used to attribute assets using smart values. For example, two custom text fields are used: "Device Name" and "Vendor Name". The number of custom fields can change, depending on the number of attributes we would like to fill.

    {
        "objectTypeId": 24,
        "attributes": [
            {
                "objectTypeAttributeId": 154,
                "objectAttributeValues": [
                    {
                        "value": "{{Device Name}}"
                    }
                ]
            },
                  {
                "objectTypeAttributeId": 217,
                "objectAttributeValues": [
                    {
                        "value": "{{Vendor Name}}"
                    }
                ]
            }
        ]
    }

      To match your configuration, you'll have to replace the values for objectTypeId and objectTypeAttributeId. - Assets (formerly Insight): How to get the IDs of object schema, object type and object from the Jira User Interface

4.

Create an Edit issue action: Select the Assets custom field which will return the object created

Additional fields: Add the JSON (webhook response smart value will be used to get the object key created) 

{
    "update" : {
        "Host" : [{"add": [{"key" : "{{webhookResponse.body.objectKey}}"}]}]
    }
}

Replace the Host custom field with your Assets custom field - Assets with Jira REST API 


最終更新日: 2024 年 10 月 24 日

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

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