Apps Scriptリファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

2019年7月4日木曜日

JIRA webhookで課題の新規更新時の情報を取得してみる


個人契約しているJIRAアカウントで、課題更新時のwebhookで取得できる情報を出力してみました。

一部の情報はマスクしています。



コード.gs
{
  "timestamp": 1562204828115,
  "webhookEvent": "jira:issue_updated",
  "issue_event_type_name": "issue_updated",
  "user": {
    "self": "https://SITENAME.atlassian.net/rest/api/2/user?accountId=ACCOUNT_ID",
    "name": "admin",
    "key": "admin",
    "accountId": "ACCOUNT_ID",
    "emailAddress": "EMAIL",
    "avatarUrls": {
      "48x48": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=48&s=48",
      "24x24": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=24&s=24",
      "16x16": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=16&s=16",
      "32x32": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=32&s=32"
    },
    "displayName": "FULLNAME",
    "active": true,
    "timeZone": "Asia/Tokyo",
    "accountType": "atlassian"
  },
  "issue": {
    "id": "10020",
    "self": "https://SITENAME.atlassian.net/rest/api/2/issue/10020",
    "key": "ISSUE_KEY",
    "fields": {
      "statuscategorychangedate": "2019-07-04T10:23:36.889+0900",
      "issuetype": {
        "self": "https://SITENAME.atlassian.net/rest/api/2/issuetype/10001",
        "id": "10001",
        "description": "Stories track functionality or features expressed as user goals.",
        "iconUrl": "https://SITENAME.atlassian.net/secure/viewavatar?size=medium&avatarId=10315&avatarType=issuetype",
        "name": "Story",
        "subtask": false,
        "avatarId": 10315
      },
      "timespent": null,
      "project": {
        "self": "https://SITENAME.atlassian.net/rest/api/2/project/10002",
        "id": "10002",
        "key": "GAS",
        "name": "Google Apps Script",
        "projectTypeKey": "software",
        "simplified": false,
        "avatarUrls": {
          "48x48": "https://SITENAME.atlassian.net/secure/projectavatar?pid=10002&avatarId=10401",
          "24x24": "https://SITENAME.atlassian.net/secure/projectavatar?size=small&s=small&pid=10002&avatarId=10401",
          "16x16": "https://SITENAME.atlassian.net/secure/projectavatar?size=xsmall&s=xsmall&pid=10002&avatarId=10401",
          "32x32": "https://SITENAME.atlassian.net/secure/projectavatar?size=medium&s=medium&pid=10002&avatarId=10401"
        }
      },
      "fixVersions": [],
      "aggregatetimespent": null,
      "resolution": null,
      "customfield_10027": null,
      "resolutiondate": null,
      "workratio": -1,
      "lastViewed": "2019-07-04T10:23:41.156+0900",
      "watches": {
        "self": "https://SITENAME.atlassian.net/rest/api/2/issue/ISSUE_KEY/watchers",
        "watchCount": 1,
        "isWatching": true
      },
      "created": "2019-07-04T10:23:36.803+0900",
      "customfield_10020": null,
      "customfield_10021": null,
      "customfield_10022": "0|i0004f:",
      "priority": {
        "self": "https://SITENAME.atlassian.net/rest/api/2/priority/3",
        "iconUrl": "https://SITENAME.atlassian.net/images/icons/priorities/medium.svg",
        "name": "Medium",
        "id": "3"
      },
      "customfield_10025": null,
      "labels": [],
      "customfield_10026": null,
      "customfield_10016": null,
      "customfield_10017": null,
      "customfield_10018": {
        "hasEpicLinkFieldDependency": false,
        "showField": false,
        "nonEditableReason": {
          "reason": "PLUGIN_LICENSE_ERROR",
          "message": "Portfolio for Jira must be licensed for the Parent Link to be available."
        }
      },
      "customfield_10019": null,
      "timeestimate": null,
      "aggregatetimeoriginalestimate": null,
      "versions": [],
      "issuelinks": [],
      "assignee": null,
      "updated": "2019-07-04T10:47:08.106+0900",
      "status": {
        "self": "https://SITENAME.atlassian.net/rest/api/2/status/10004",
        "description": "",
        "iconUrl": "https://SITENAME.atlassian.net/",
        "name": "To Do",
        "id": "10004",
        "statusCategory": {
          "self": "https://SITENAME.atlassian.net/rest/api/2/statuscategory/2",
          "id": 2,
          "key": "new",
          "colorName": "blue-gray",
          "name": "New"
        }
      },
      "components": [],
      "timeoriginalestimate": null,
      "description": null,
      "customfield_10010": null,
      "customfield_10014": null,
      "timetracking": {},
      "customfield_10015": null,
      "customfield_10005": null,
      "customfield_10006": null,
      "security": null,
      "customfield_10007": null,
      "customfield_10008": null,
      "attachment": [],
      "aggregatetimeestimate": null,
      "customfield_10009": null,
      "summary": "タイトル変更",
      "creator": {
        "self": "https://SITENAME.atlassian.net/rest/api/2/user?accountId=ACCOUNT_ID",
        "name": "admin",
        "key": "admin",
        "accountId": "ACCOUNT_ID",
        "emailAddress": "EMAIL",
        "avatarUrls": {
          "48x48": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=48&s=48",
          "24x24": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=24&s=24",
          "16x16": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=16&s=16",
          "32x32": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=32&s=32"
        },
        "displayName": "FULLNAME",
        "active": true,
        "timeZone": "Asia/Tokyo",
        "accountType": "atlassian"
      },
      "subtasks": [],
      "reporter": {
        "self": "https://SITENAME.atlassian.net/rest/api/2/user?accountId=ACCOUNT_ID",
        "name": "admin",
        "key": "admin",
        "accountId": "ACCOUNT_ID",
        "emailAddress": "EMAIL",
        "avatarUrls": {
          "48x48": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=48&s=48",
          "24x24": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=24&s=24",
          "16x16": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=16&s=16",
          "32x32": "https://avatar-cdn.atlassian.com/ACCOUNT_ID?by=id&sg=ID=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSK-0.png&size=32&s=32"
        },
        "displayName": "FULLNAME",
        "active": true,
        "timeZone": "Asia/Tokyo",
        "accountType": "atlassian"
      },
      "aggregateprogress": {
        "progress": 0,
        "total": 0
      },
      "customfield_10000": "{}",
      "customfield_10001": null,
      "customfield_10002": null,
      "customfield_10003": null,
      "customfield_10004": null,
      "environment": null,
      "duedate": null,
      "progress": {
        "progress": 0,
        "total": 0
      },
      "votes": {
        "self": "https://SITENAME.atlassian.net/rest/api/2/issue/ISSUE_KEY/votes",
        "votes": 0,
        "hasVoted": false
      }
    }
  },
  "changelog": {
    "id": "10025",
    "items": [
      {
        "field": "summary",
        "fieldtype": "jira",
        "fieldId": "summary",
        "from": null,
        "fromString": "新しいストーリー2",
        "to": null,
        "toString": "タイトル変更"
      }
    ]
  }
}




関連記事

JIRAのWebhookを利用してリアルタイムで更新をキャッチする

Latest post

Googleドキュメントに見出しを追加したい

今回の例では、ドキュメントの末尾に「見出しD」 を追加します。 見出しA, B, C, Dのスタイルは、見出し3 ( HEADING3 ) に設定しています。  下記Code.gsの  GOOGLE_DOCUMENT_URL を設定して  addHeadingToEnd()  を...