JIRAのstatusをAPIで更新するにはtransitionでやるらしい
https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-transitions-post
- transitoin idを確認する
https://SITENAME.atlassian.net/rest/api/2/issue/ISSUE_KEY/?expand=transitions.fields - transition idをPOSTで更新する
コード.gs
function get_jira_token() { var id = "LOGIN_EMAIL"; var pw = "LOGIN_PASSWORD"; var jira_token = Utilities.base64Encode(id + ":" + pw); return jira_token; } function get_base_url() { var base_url = "https://SITENAME.atlassian.net/rest/api/2/issue/"; return base_url; } /************************************ まずはtransitionsを取得してログに出して変更したいステータスのidを見つける ...{"id":"31","name":"完了"... などと取得できる ************************************/ function get_issue() { var token = get_jira_token(); var key = "KEY-1"; var options = { contentType: "application/json", headers: {"Authorization": " Basic " + token} }; var url = get_base_url() + key + "?expand=transitions.fields"; var response = UrlFetchApp.fetch(url, options); Logger.log(response); } /************************************ transitionを変更する var transitions = {"transition": {"id": "31"}} などと書いて変更する ************************************/ function change_transition() { var token = get_jira_token(); var payload = get_payload(); var options = get_options(token, payload); var url = get_url(); UrlFetchApp.fetch(url, options); } function get_url(){ var key = "KEY-1"; var url = get_base_url() + key + "/transitions"; return url; } function get_payload(values) { var transitions = {"transition": {"id": "31"}} var payload = JSON.stringify(transitions); return payload; } function get_options(token, payload) { var options = { method: "post", payload: payload, contentType: "application/json", headers: {"Authorization": " Basic " + token} } return options; } |
参考
Do transition
https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-transitions-post