LoginSignup
6
1

More than 1 year has passed since last update.

GitLab APIからMerge Requestの情報を取得する

Last updated at Posted at 2020-08-15

はじめに

GitLabではREST API が提供されています。
今回はそのAPIを使ってMRの情報を取得するまでを記載いたします。

・Merge requests API

1.gitLabApiを使うためにトークンを作成する

まずはgitLabApiを使うためにトークンを作成します。

・gitlabの右上のアカウントアイコンSettingsを選択します。
picture_pc_36d1d13d217d80aa01caebf81660179c.png

・サイドバーからAccess Tokensを選択。
bbb.png

・NameとScopesのapiにチェックを入れます。今回は期限などはないのでExpiers atは入力無しです。Create personal access tokenをクリックします。
ccc.png

・これでトークンの生成は完了です。
ddd.png

2.gitLabApiからMR情報を取得

トークンが完成したので実際にMerge Requestの情報を取得してみましょう。

取得したいプロジェクトIDから先ほど発行したトークンをパラメータに設定することでMRの情報を取得することができます。

curl https://" + [GitLabのHost] /api/v4/projects/取得したいMRのProjectID/merge_requests?private_token='発行したトークン'

終わりに

・Merge requests API

上記ドキュメントの Parameters で様々な取得条件を設定することができます。
情報を取得して運用の自動化やなど行えるかと思います。

6
1
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
6
1