正式なドキュメントは英語版であり、この日本語訳はAI支援翻訳により作成された参考用のものです。日本語訳の一部の内容は人間によるレビューがまだ行われていないため、翻訳のタイミングにより英語版との間に差異が生じることがあります。最新かつ正確な情報については、英語版をご参照ください。

外部ステータスチェックAPI

  • プラン: Ultimate
  • 提供形態: GitLab.com、GitLab Self-Managed、GitLab Dedicated

このAPIを使用して、external status checksを管理します。

プロジェクトの外部ステータスチェックサービスを取得

次のエンドポイントを使用すると、プロジェクトの外部ステータスチェックサービスに関する情報をリクエストできます:

GET /projects/:id/external_status_checks

パラメータ:

属性必須説明
id整数はいプロジェクトのID
[
  {
    "id": 1,
    "name": "Compliance Tool",
    "project_id": 6,
    "external_url": "https://gitlab.com/example/compliance-tool",
    "hmac": true,
    "protected_branches": [
      {
        "id": 14,
        "project_id": 6,
        "name": "main",
        "created_at": "2020-10-12T14:04:50.787Z",
        "updated_at": "2020-10-12T14:04:50.787Z",
        "code_owner_approval_required": false
      }
    ]
  }
]

外部ステータスチェックサービスを作成

次のエンドポイントを使用すると、プロジェクトの新しい外部ステータスチェックサービスを作成できます:

POST /projects/:id/external_status_checks

外部ステータスチェックは、該当するすべてのマージリクエストに関する情報を、定義された外部サービスに送信します。これには、機密のマージリクエストが含まれます。

属性必須説明
id整数はいプロジェクトのID
name文字列はい外部ステータスチェックサービスの表示名
external_url文字列はい外部ステータスチェックサービスのURL
shared_secret文字列いいえ外部ステータスチェックのHMACシークレット
protected_branch_idsarray<Integer>いいえルールをスコープする保護ブランチのID

外部ステータスチェックサービスを更新

次のエンドポイントを使用すると、プロジェクトの既存の外部ステータスチェックを更新できます:

PUT /projects/:id/external_status_checks/:check_id
属性必須説明
id整数はいプロジェクトのID
check_id整数はい外部ステータスチェックサービスのID
name文字列いいえ外部ステータスチェックサービスの表示名
external_url文字列いいえ外部ステータスチェックサービスのURL
shared_secret文字列いいえ外部ステータスチェックのHMACシークレット
protected_branch_idsarray<Integer>いいえルールをスコープする保護ブランチのID

外部ステータスチェックサービスを削除

次のエンドポイントを使用すると、プロジェクトの外部ステータスチェックサービスを削除できます:

DELETE /projects/:id/external_status_checks/:check_id
属性必須説明
check_id整数はい外部ステータスチェックサービスのID
id整数はいプロジェクトのID

マージリクエストのステータスチェックをリスト表示

単一のマージリクエストについて、それに適用される外部ステータスチェックサービスとそのステータスをリスト表示します。

GET /projects/:id/merge_requests/:merge_request_iid/status_checks

パラメータ:

属性必須説明
id整数はいプロジェクトのID
merge_request_iid整数はいマージリクエストのIID
[
    {
        "id": 2,
        "name": "Service 1",
        "external_url": "https://gitlab.com/test-endpoint",
        "status": "passed"
    },
    {
        "id": 1,
        "name": "Service 2",
        "external_url": "https://gitlab.com/test-endpoint-2",
        "status": "pending"
    }
]

外部ステータスチェックのステータスを設定

単一のマージリクエストの場合、APIを使用して、外部サービスによるチェックにマージリクエストが合格したことをGitLabに通知します。外部チェックのステータスを設定するには、使用するパーソナルアクセストークンが、マージリクエストのターゲットプロジェクトに対する少なくともデベロッパーロールを持つユーザーに属している必要があります。

このAPIコールは、マージリクエスト自体を承認する権限を持つ任意のユーザーとして実行します。

POST /projects/:id/merge_requests/:merge_request_iid/status_check_responses

パラメータ:

属性必須説明
id整数はいプロジェクトのID
merge_request_iid整数はいマージリクエストのIID
sha文字列はいソースブランチのHEADのSHA
external_status_check_id整数はい外部ステータスチェックのID
status文字列いいえチェックを保留中としてマークするにはpending、チェックに合格するにはpassed、失敗させるにはfailedに設定します

shaは、マージリクエストのソースブランチのHEADにあるSHAである必要があります。

マージリクエストの失敗したステータスチェックを再試行

単一のマージリクエストについて、指定された失敗した外部ステータスチェックを再試行します。マージリクエストが変更されていなくても、このエンドポイントはマージリクエストの現在の状態を定義済みの外部サービスに再送信します。

POST /projects/:id/merge_requests/:merge_request_iid/status_checks/:external_status_check_id/retry

パラメータ:

属性必須説明
id整数はいプロジェクトのID
merge_request_iid整数はいマージリクエストのIID
external_status_check_id整数はい失敗した外部ステータスチェックのID

レスポンス

成功した場合、ステータスコードは202です。

{
    "message": "202 Accepted"
}

ステータスチェックがすでに合格している場合、ステータスコードは422です

{
    "message": "External status check must be failed"
}

外部サービスに送信されるペイロード

{
  "object_kind": "merge_request",
  "event_type": "merge_request",
  "user": {
    "id": 1,
    "name": "Administrator",
    "username": "root",
    "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
    "email": "[REDACTED]"
  },
  "project": {
    "id": 6,
    "name": "Flight",
    "description": "Ipsa minima est consequuntur quisquam.",
    "web_url": "http://example.com/flightjs/Flight",
    "avatar_url": null,
    "git_ssh_url": "ssh://example.com/flightjs/Flight.git",
    "git_http_url": "http://example.com/flightjs/Flight.git",
    "namespace": "Flightjs",
    "visibility_level": 20,
    "path_with_namespace": "flightjs/Flight",
    "default_branch": "main",
    "ci_config_path": null,
    "homepage": "http://example.com/flightjs/Flight",
    "url": "ssh://example.com/flightjs/Flight.git",
    "ssh_url": "ssh://example.com/flightjs/Flight.git",
    "http_url": "http://example.com/flightjs/Flight.git"
  },
  "object_attributes": {
    "assignee_id": null,
    "author_id": 1,
    "created_at": "2022-12-07 07:53:43 UTC",
    "description": "",
    "head_pipeline_id": 558,
    "id": 144,
    "iid": 4,
    "last_edited_at": null,
    "last_edited_by_id": null,
    "merge_commit_sha": null,
    "merge_error": null,
    "merge_params": {
      "force_remove_source_branch": "1"
    },
    "merge_status": "can_be_merged",
    "merge_user_id": null,
    "merge_when_pipeline_succeeds": false,
    "milestone_id": null,
    "source_branch": "root-main-patch-30152",
    "source_project_id": 6,
    "state_id": 1,
    "target_branch": "main",
    "target_project_id": 6,
    "time_estimate": 0,
    "title": "Update README.md",
    "updated_at": "2022-12-07 07:53:43 UTC",
    "updated_by_id": null,
    "url": "http://example.com/flightjs/Flight/-/merge_requests/4",
    "source": {
      "id": 6,
      "name": "Flight",
      "description": "Ipsa minima est consequuntur quisquam.",
      "web_url": "http://example.com/flightjs/Flight",
      "avatar_url": null,
      "git_ssh_url": "ssh://example.com/flightjs/Flight.git",
      "git_http_url": "http://example.com/flightjs/Flight.git",
      "namespace": "Flightjs",
      "visibility_level": 20,
      "path_with_namespace": "flightjs/Flight",
      "default_branch": "main",
      "ci_config_path": null,
      "homepage": "http://example.com/flightjs/Flight",
      "url": "ssh://example.com/flightjs/Flight.git",
      "ssh_url": "ssh://example.com/flightjs/Flight.git",
      "http_url": "http://example.com/flightjs/Flight.git"
    },
    "target": {
      "id": 6,
      "name": "Flight",
      "description": "Ipsa minima est consequuntur quisquam.",
      "web_url": "http://example.com/flightjs/Flight",
      "avatar_url": null,
      "git_ssh_url": "ssh://example.com/flightjs/Flight.git",
      "git_http_url": "http://example.com/flightjs/Flight.git",
      "namespace": "Flightjs",
      "visibility_level": 20,
      "path_with_namespace": "flightjs/Flight",
      "default_branch": "main",
      "ci_config_path": null,
      "homepage": "http://example.com/flightjs/Flight",
      "url": "ssh://example.com/flightjs/Flight.git",
      "ssh_url": "ssh://example.com/flightjs/Flight.git",
      "http_url": "http://example.com/flightjs/Flight.git"
    },
    "last_commit": {
      "id": "141be9714669a4c1ccaa013c6a7f3e462ff2a40f",
      "message": "Update README.md",
      "title": "Update README.md",
      "timestamp": "2022-12-07T07:52:11+00:00",
      "url": "http://example.com/flightjs/Flight/-/commit/141be9714669a4c1ccaa013c6a7f3e462ff2a40f",
      "author": {
        "name": "Administrator",
        "email": "admin@example.com"
      }
    },
    "work_in_progress": false,
    "total_time_spent": 0,
    "time_change": 0,
    "human_total_time_spent": null,
    "human_time_change": null,
    "human_time_estimate": null,
    "assignee_ids": [
    ],
    "reviewer_ids": [
    ],
    "labels": [
    ],
    "state": "opened",
    "blocking_discussions_resolved": true,
    "first_contribution": false,
    "detailed_merge_status": "mergeable"
  },
  "labels": [
  ],
  "changes": {
  },
  "repository": {
    "name": "Flight",
    "url": "ssh://example.com/flightjs/Flight.git",
    "description": "Ipsa minima est consequuntur quisquam.",
    "homepage": "http://example.com/flightjs/Flight"
  },
  "external_approval_rule": {
    "id": 1,
    "name": "QA",
    "external_url": "https://example.com/"
  }
}