7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

cURL + jq でGithub IssuesをCSV出力する (v3 API)

Last updated at Posted at 2019-05-13

はじめに

Github Issuesでチケット管理している場合、CSVファイルとして出力したい場合がよくあります。例えば、セールスチームや、CSチームへどんなチケットがあるのかを共有したい時など。

やり方

要件

  1. openのissueを取得する。
  2. エクセル or Numbersで確認できるCSVであること
  3. メンバーが簡単に実行環境を整えられること

CSV出力

curl -u ":github_username" https://api.github.com/repos/:repository/issues\?per_page\=1000\&page\=1\&state\=open |\
 jq -r '["id","title"], (.[] | [.id,.title]) | @csv' > latest_issues.csv

:github_usernam => Githubのユーザー名
:repository => 対象のリポジトリ

パラメータ 説明
per_page 1ページあたりのデータ量
page 何ページ目なのか
state ステータスです。open / closed / all で指定します。デフォルト open です。

公式ドキュメント:
Issues: https://developer.github.com/v3/issues/#parameters
Pagination: https://developer.github.com/v3/#pagination

サンプル

ruby のissuesを取得して、CSV出力してみようと思います。

curl -u "fukmaru" https://api.github.com/repos/ruby/ruby/issues\?state\=open | jq -r '["id","title"], (.[] | [.id,.title]) | @csv' > latest_issues.csv

-u "fukmaru" は、私個人の物ですので、適切に変えてみてください。 fukmaru

こんなCSVができます。

./latest_issues.csv
"id","title"
443172349,"Harden fstr against multi-level shared strings"
443170985,"String#b: Don't depend on dependent string"
443141205,"Optimize CGI.escape and CGI.unescape"
443133755,"Optimize make URI::Util.make_components_hash"
443060039,"`Module#deprecate_constant` with message"
442414692,"Add object packing strategies for compaction"
441982364,"Write barrier should execute on target array when it is shared"
441266631,"Make Module#name and Symbol#to_s return their internal fstrings"
441245077,"Support XDG_*"
441174010,"Add an optional `inherit` argument to Module#autoload? (Feature #15777)"
440489120,"Add `Array#extract!`, `Hash#extract!`, and `ENV::extract!`"
440442248,"My wish for today is to fix the worst line of documentation in the pr…"
440324730,"Add Hash#except ENV#except"
439855458,"Add details about parameters to define_method doc"
439145969,"Add `exception` option to OpenStruct#initialize"
438126001,"Modify `ISeq#disasm` to provide the location as well as the default argument part."
437429354,"Reduce the minimum string buffer size from 127 to 63 bytes"
436227147,"NetBSD native support of explicit_bzero's like feature"
436081560,"IRB is improved with Reline and RDoc, take 2"
435970820,"New attribute trace_equivalent"
435923295,"Let memory sizes of the various IMEMO object types be reflected correctly"
435511039,"Fix release post output for tool/format-release"
434087025,"Replace use of _id2ref with WeakMap."
433831467,"Proposal: Add Time#ceil"
433581320,"Feature #15771: Add `String#split` option to set split_type string when a single space separator"
433577719,"Bugfix 15360: release mutex before checking for interrupts"
432866629,"Explicitly initialise encodings on init to remove branches on encoding lookup"
432809509,"Allow immediate objects to be used as WeakMap values"
431651217,"Split to smaller commits"
431614115,"Add compactor"

(2019/5/13 現在)

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?