Last active
August 29, 2015 14:22
-
-
Save king-panda/6bff8d97410e6ad84db0 to your computer and use it in GitHub Desktop.
【GAS】Backlogの残タスク(課題チケット)をGASで取得してチャットワークに流す ref: http://qiita.com/kingpanda/items/44667f2ddc39e760ea8b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function task() { | |
// スプレットシート取得 | |
var mySS = SpreadsheetApp.openById("***スプレットシートのID***"); | |
// スプレットシートの書き込む位置 | |
var range= mySS.getSheetByName("**シートの名前**").getRange(1, 1); | |
// BacklogプロジェクトのID | |
var pjid = **PJ ID**; | |
// ChatWorkに投稿する本文 | |
var honbun = ""; | |
// APIキーでBacklog認証&取得 | |
var resissue = UrlFetchApp.fetch("https://***.backlog.jp/api/v2/issues?apiKey=*******APIキー*******&projectId[]="+pjid+"&statusId[]=1&statusId[]=2&statusId[]=3&order=&count=100"); | |
if (resissue.getResponseCode() != 200) { | |
return false; | |
} | |
var issuelist = JSON.parse(resissue.getContentText()); | |
// 一旦、シートをクリアにする | |
mySS.getSheetByName("**シートの名前**").getRange("A2:G"+issuelist.length+"").clearContent(); | |
for(var i=1; i<issuelist.length; i++) { | |
// スプレッドシートに書き込む | |
range.offset(i, 0).setValue(issuelist[i]["issueKey"]); | |
range.offset(i, 1).setValue(issuelist[i]["summary"]); | |
range.offset(i, 2).setValue(issuelist[i]["description"]); | |
range.offset(i, 3).setValue(issuelist[i]["assignee"]["name"]); | |
range.offset(i, 4).setValue(issuelist[i]["priority"]["name"]); | |
range.offset(i, 5).setValue(issuelist[i]["status"]["name"]); | |
range.offset(i, 6).setValue(issuelist[i]["dueDate"]); | |
// 投稿するメッセージの本文 | |
honbun += issuelist[i]["issueKey"] + " "; | |
honbun += issuelist[i]["summary"] + " "; | |
honbun += "担当:" + issuelist[i]["assignee"]["name"] + " "; | |
honbun += "優先度:" + issuelist[i]["priority"]["name"] + " "; | |
honbun += "ステータス:" + issuelist[i]["status"]["name"] + "\n"; | |
honbun += "https://****.backlog.jp/view/" + issuelist[i]["issueKey"] + "\n[hr]"; | |
} | |
//ここからはChatWork | |
var client = ChatWorkClient.factory({token: "***ChatWorkのAPIキー***"}); | |
/* 決められた記法をもとに整形。 | |
投稿する部屋のIDと共に | |
メッセージを投稿します。*/ | |
client.sendMessage({ | |
room_id:***room ID***, | |
body: "[info][title]残タスク一覧[/title]\n"+honbun+"\n現在の残タスクになります。完了しているタスクについてはステータスを変更してください。\n [/info]" | |
}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://***.backlog.jp/api/v2/issues?apiKey=*******APIキー*******&projectId[]="+pjid+"&statusId[]=1&statusId[]=2&statusId[]=3&order=&count=100 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment