LoginSignup
5
5

More than 5 years have passed since last update.

GitLab API | gitlab gem で Issue のコメント一覧を取得する

Posted at

GitLab API | gitlab gem で Issue のコメント一覧を取得する

概要

gitlab gem で Issue のコメント一覧を取得します。

シグネチャ

issue_notes(project, issue)

project => プロジェクトID
issue => IssueID

サンプル

プロジェクト10件の、各Issue10件に対するコメントを取得します、

require 'gitlab'

Gitlab.configure do |config|
  config.endpoint       = 'http://some_path/api/v3' 
  config.private_token  = 'your token'
end
Gitlab.projects(per_page: 10).each do |project|
  Gitlab.issues(project.id, per_page: 10).each do |issue|
    issue_notes = Gitlab.issue_notes(project.id, issue.id)
    if issue_notes.size == 0
      puts "no issue notes"
    else
      puts issue_notes.first.body
    end
  end
end

出力例

some comment1
some comment2
some comment3

参照

5
5
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
5
5