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

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

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

このAPIを使用して、外部ステータスチェックを管理します。

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

次のエンドポイントを使用して、プロジェクトの外部ステータスチェックサービスに関する情報を取得する:

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"
    }
]

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

単一のマージリクエストの外部ステータスチェックのステータスを設定し、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/"
  }
}