InfoGrab DocsInfoGrab Docs

프로젝트 웹훅 API

요약

- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated 이 API를 사용하여 프로젝트 웹훅을 관리합니다. GitLab 17.1에서 name 및 description 속성이 도입됨.

  - 
  Tier: Free, Premium, Ultimate

- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

이 API를 사용하여 프로젝트 웹훅을 관리합니다. 프로젝트 웹훅은 전체 인스턴스에 영향을 미치는 시스템 훅 및 그룹의 모든 프로젝트와 하위 그룹에 영향을 미치는 그룹 웹훅과 다릅니다.

사전 요건:

  • 프로젝트에 대한 관리자 권한이 있거나 Maintainer 또는 Owner 권한이 있어야 합니다.

프로젝트의 웹훅 목록 조회#

프로젝트 웹훅 목록을 가져옵니다.

GET /projects/:id/hooks

지원되는 속성:

속성 유형 필수 설명
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.

프로젝트 웹훅 조회#

History

  • GitLab 17.1에서 namedescription 속성이 도입됨.

  • GitLab 19.0에서 token_presentsigning_token_present 속성이 도입됨.

프로젝트의 지정된 웹훅을 조회합니다.

GET /projects/:id/hooks/:hook_id

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.

응답 예시:

{
  "id": 1,
  "url": "http://example.com/hook",
  "name": "Hook name",
  "description": "Hook description",
  "project_id": 3,
  "push_events": true,
  "push_events_branch_filter": "",
  "issues_events": true,
  "confidential_issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "confidential_note_events": true,
  "job_events": true,
  "pipeline_events": true,
  "wiki_page_events": true,
  "deployment_events": true,
  "releases_events": true,
  "milestone_events": true,
  "feature_flag_events": true,
  "enable_ssl_verification": true,
  "repository_update_events": false,
  "alert_status": "executable",
  "disabled_until": null,
  "url_variables": [ ],
  "created_at": "2012-10-12T17:04:47Z",
  "resource_access_token_events": true,
  "custom_webhook_template": "{\"event\":\"{{object_kind}}\"}",
  "custom_headers": [
    {
      "key": "Authorization"
    }
  ],
  "token_present": false,
  "signing_token_present": false
}

프로젝트 웹훅 이벤트 목록 조회#

History

시작 날짜로부터 최근 7일간 지정된 프로젝트 웹훅의 모든 이벤트를 나열합니다.

GET /projects/:id/hooks/:hook_id/events

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
status integer or string No 이벤트의 응답 상태 코드. 예: 200 또는 500. 상태 카테고리별로 검색 가능: successful (200-299), client_failure (400-499), server_failure (500-599).
page integer No 조회할 페이지. 기본값은 1.
per_page integer No 페이지당 반환할 레코드 수. 기본값은 20.

응답 예시:

[
  {
    "id": 1,
    "url": "https://example.net/",
    "trigger": "push_hooks",
    "request_headers": {
      "Content-Type": "application/json",
      "User-Agent": "GitLab/17.1.0-pre",
      "Idempotency-Key": "3a427872-00df-429c-9bc9-a9475de2efe4",
      "X-Gitlab-Event": "Push Hook",
      "X-Gitlab-Webhook-UUID": "3c5c0404-c866-44bc-a5f6-452bb1bfc76e",
      "X-Gitlab-Instance": "https://gitlab.example.com",
      "X-Gitlab-Event-UUID": "9cebe914-4827-408f-b014-cfa23a47a35f",
      "X-Gitlab-Token": "[REDACTED]"
    },
    "request_data": {
      "object_kind": "push",
      "event_name": "push",
      "before": "468abc807a2b2572f43e72c743b76cee6db24025",
      "after": "f15b32277d2c55c6c595845a87109b09c913c556",
      "ref": "refs/heads/master",
      "ref_protected": true,
      "checkout_sha": "f15b32277d2c55c6c595845a87109b09c913c556",
      "message": null,
      "user_id": 1,
      "user_name": "Administrator",
      "user_username": "root",
      "user_email": null,
      "user_avatar": "https://www.gravatar.com/avatar/13efe0d4559475ba84ecc802061febbdea6e224fcbffd7ec7da9cd431845299c?s=80&d=identicon",
      "project_id": 7,
      "project": {
        "id": 7,
        "name": "Flight",
        "description": "Incidunt ea ab officia a veniam.",
        "web_url": "https://gitlab.example.com/flightjs/Flight",
        "avatar_url": null,
        "git_ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "git_http_url": "https://gitlab.example.com/flightjs/Flight.git",
        "namespace": "Flightjs",
        "visibility_level": 10,
        "path_with_namespace": "flightjs/Flight",
        "default_branch": "master",
        "ci_config_path": null,
        "homepage": "https://gitlab.example.com/flightjs/Flight",
        "url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "http_url": "https://gitlab.example.com/flightjs/Flight.git"
      },
      "commits": [
        {
          "id": "f15b32277d2c55c6c595845a87109b09c913c556",
          "message": "v1.5.2\n",
          "title": "v1.5.2",
          "timestamp": "2017-06-19T14:39:53-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/f15b32277d2c55c6c595845a87109b09c913c556",
          "author": {
            "name": "Andrew Lunny",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        },
        {
          "id": "8749d49930866a4871fa086adbd7d2057fcc3ebb",
          "message": "Merge pull request #378 from flightjs/alunny/publish_lib\n\npublish lib and index to npm",
          "title": "Merge pull request #378 from flightjs/alunny/publish_lib",
          "timestamp": "2017-06-16T10:26:39-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/8749d49930866a4871fa086adbd7d2057fcc3ebb",
          "author": {
            "name": "angus croll",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        },
        {
          "id": "468abc807a2b2572f43e72c743b76cee6db24025",
          "message": "publish lib and index to npm\n",
          "title": "publish lib and index to npm",
          "timestamp": "2017-06-16T10:23:04-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/468abc807a2b2572f43e72c743b76cee6db24025",
          "author": {
            "name": "Andrew Lunny",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        }
      ],
      "total_commits_count": 3,
      "push_options": {},
      "repository": {
        "name": "Flight",
        "url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "description": "Incidunt ea ab officia a veniam.",
        "homepage": "https://gitlab.example.com/flightjs/Flight",
        "git_http_url": "https://gitlab.example.com/flightjs/Flight.git",
        "git_ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "visibility_level": 10
      }
    },
    "response_headers": {
      "Date": "Sun, 26 May 2024 03:03:17 GMT",
      "Content-Type": "application/json; charset=utf-8",
      "Content-Length": "16",
      "Connection": "close",
      "X-Powered-By": "Express",
      "Access-Control-Allow-Origin": "*",
      "X-Pd-Status": "sent to primary"
    },
    "response_body": "{\"success\":true}",
    "execution_duration": 1.0906479999999874,
    "response_status": "200"
  },
  {
    "id": 2,
    "url": "https://example.net/",
    "trigger": "push_hooks",
    "request_headers": {
      "Content-Type": "application/json",
      "User-Agent": "GitLab/17.1.0-pre",
      "Idempotency-Key": "7c6e0583-49f2-4dc5-a50b-4c0bcf3c1b27",
      "X-Gitlab-Event": "Push Hook",
      "X-Gitlab-Webhook-UUID": "a753eedb-1d72-4549-9ca7-eac8ea8e50dd",
      "X-Gitlab-Instance": "https://gitlab.example.com",
      "X-Gitlab-Event-UUID": "842d7c3e-3114-4396-8a95-66c084d53cb1",
      "X-Gitlab-Token": "[REDACTED]"
    },
    "request_data": {
      "object_kind": "push",
      "event_name": "push",
      "before": "468abc807a2b2572f43e72c743b76cee6db24025",
      "after": "f15b32277d2c55c6c595845a87109b09c913c556",
      "ref": "refs/heads/master",
      "ref_protected": true,
      "checkout_sha": "f15b32277d2c55c6c595845a87109b09c913c556",
      "message": null,
      "user_id": 1,
      "user_name": "Administrator",
      "user_username": "root",
      "user_email": null,
      "user_avatar": "https://www.gravatar.com/avatar/13efe0d4559475ba84ecc802061febbdea6e224fcbffd7ec7da9cd431845299c?s=80&d=identicon",
      "project_id": 7,
      "project": {
        "id": 7,
        "name": "Flight",
        "description": "Incidunt ea ab officia a veniam.",
        "web_url": "https://gitlab.example.com/flightjs/Flight",
        "avatar_url": null,
        "git_ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "git_http_url": "https://gitlab.example.com/flightjs/Flight.git",
        "namespace": "Flightjs",
        "visibility_level": 10,
        "path_with_namespace": "flightjs/Flight",
        "default_branch": "master",
        "ci_config_path": null,
        "homepage": "https://gitlab.example.com/flightjs/Flight",
        "url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "http_url": "https://gitlab.example.com/flightjs/Flight.git"
      },
      "commits": [
        {
          "id": "f15b32277d2c55c6c595845a87109b09c913c556",
          "message": "v1.5.2\n",
          "title": "v1.5.2",
          "timestamp": "2017-06-19T14:39:53-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/f15b32277d2c55c6c595845a87109b09c913c556",
          "author": {
            "name": "Andrew Lunny",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        },
        {
          "id": "8749d49930866a4871fa086adbd7d2057fcc3ebb",
          "message": "Merge pull request #378 from flightjs/alunny/publish_lib\n\npublish lib and index to npm",
          "title": "Merge pull request #378 from flightjs/alunny/publish_lib",
          "timestamp": "2017-06-16T10:26:39-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/8749d49930866a4871fa086adbd7d2057fcc3ebb",
          "author": {
            "name": "angus croll",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        },
        {
          "id": "468abc807a2b2572f43e72c743b76cee6db24025",
          "message": "publish lib and index to npm\n",
          "title": "publish lib and index to npm",
          "timestamp": "2017-06-16T10:23:04-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/468abc807a2b2572f43e72c743b76cee6db24025",
          "author": {
            "name": "Andrew Lunny",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        }
      ],
      "total_commits_count": 3,
      "push_options": {},
      "repository": {
        "name": "Flight",
        "url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "description": "Incidunt ea ab officia a veniam.",
        "homepage": "https://gitlab.example.com/flightjs/Flight",
        "git_http_url": "https://gitlab.example.com/flightjs/Flight.git",
        "git_ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "visibility_level": 10
      }
    },
    "response_headers": {
      "Date": "Sun, 26 May 2024 03:03:19 GMT",
      "Content-Type": "application/json; charset=utf-8",
      "Content-Length": "16",
      "Connection": "close",
      "X-Powered-By": "Express",
      "Access-Control-Allow-Origin": "*",
      "X-Pd-Status": "sent to primary"
    },
    "response_body": "{\"success\":true}",
    "execution_duration": 1.0716120000000728,
    "response_status": "200"
  }
]

프로젝트 웹훅 이벤트 재전송#

History

특정 프로젝트 웹훅 이벤트를 재전송합니다.

이 엔드포인트에는 각 프로젝트 웹훅 및 인증된 사용자에 대해 분당 5회 요청의 속도 제한이 있습니다. GitLab Self-Managed 및 GitLab Dedicated에서 이 제한을 비활성화하려면 관리자가 web_hook_event_resend_api_endpoint_rate_limit라는 이름의 기능 플래그를 비활성화할 수 있습니다.

POST /projects/:id/hooks/:hook_id/events/:hook_event_id/resend

지원되는 속성:

속성 유형 필수 설명
hook_event_id integer Yes 프로젝트 웹훅 이벤트의 ID.
hook_id integer Yes 프로젝트 웹훅의 ID.

응답 예시:

{
  "response_status": 200
}

프로젝트에 웹훅 추가#

History

  • GitLab 17.1에서 namedescription 속성이 도입됨.

  • GitLab 19.0에서 signing_token 속성이 webhook_signing_token이라는 이름의 플래그와 함께 도입됨. 기본적으로 활성화됨.

  • GitLab 19.1에서 기능 플래그 webhook_signing_token제거됨.

지정된 프로젝트에 웹훅을 추가합니다.

POST /projects/:id/hooks

지원되는 속성:

속성 유형 필수 설명
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
url string Yes 프로젝트 웹훅 URL.
branch_filter_strategy string No 브랜치별로 푸시 이벤트를 필터링합니다. 가능한 값: wildcard (기본값), regex, all_branches.
confidential_issues_events boolean No 비밀 이슈 이벤트 시 프로젝트 웹훅 트리거.
confidential_note_events boolean No 비밀 노트 이벤트 시 프로젝트 웹훅 트리거.
custom_headers array No 프로젝트 웹훅의 커스텀 헤더.
custom_webhook_template string No 프로젝트 웹훅의 커스텀 웹훅 템플릿.
deployment_events boolean No 배포 이벤트 시 프로젝트 웹훅 트리거.
description string No 웹훅 설명.
enable_ssl_verification boolean No 웹훅 트리거 시 SSL 검증 활성화.
feature_flag_events boolean No 기능 플래그 이벤트 시 프로젝트 웹훅 트리거.
issues_events boolean No 이슈 이벤트 시 프로젝트 웹훅 트리거.
job_events boolean No job 이벤트 시 프로젝트 웹훅 트리거.
merge_requests_events boolean No 머지 리퀘스트 이벤트 시 프로젝트 웹훅 트리거.
milestone_events boolean No 마일스톤 이벤트 시 프로젝트 웹훅 트리거.
name string No 프로젝트 웹훅 이름.
note_events boolean No 노트 이벤트 시 프로젝트 웹훅 트리거.
pipeline_events boolean No 파이프라인 이벤트 시 프로젝트 웹훅 트리거.
push_events boolean No 푸시 이벤트 시 프로젝트 웹훅 트리거.
push_events_branch_filter string No 일치하는 브랜치의 푸시 이벤트에만 프로젝트 웹훅 트리거.
releases_events boolean No 릴리스 이벤트 시 프로젝트 웹훅 트리거.
resource_access_token_events boolean No 프로젝트 액세스 토큰 만료 이벤트 시 프로젝트 웹훅 트리거.
signing_token string No webhook-signature 헤더를 계산하는 데 사용되는 HMAC 서명 토큰. 32바이트 키를 인코딩하는 whsec_ 형식이어야 합니다. 응답에 반환되지 않습니다.
tag_push_events boolean No 태그 푸시 이벤트 시 프로젝트 웹훅 트리거.
token string No 수신된 페이로드를 검증하기 위한 시크릿 토큰. 응답에 반환되지 않습니다.
wiki_page_events boolean No 위키 이벤트 시 프로젝트 웹훅 트리거.
resource_deploy_token_events boolean No 프로젝트 배포 토큰 만료 이벤트 시 프로젝트 웹훅 트리거.

프로젝트 웹훅 업데이트#

History

  • GitLab 17.1에서 namedescription 속성이 도입됨.

  • GitLab 19.0에서 signing_token 속성이 webhook_signing_token이라는 이름의 플래그와 함께 도입됨. 기본적으로 활성화됨.

  • GitLab 19.1에서 기능 플래그 webhook_signing_token제거됨.

지정된 프로젝트의 프로젝트 웹훅을 업데이트합니다.

PUT /projects/:id/hooks/:hook_id

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
url string Yes 프로젝트 웹훅 URL.
branch_filter_strategy string No 브랜치별로 푸시 이벤트를 필터링합니다. 가능한 값: wildcard (기본값), regex, all_branches.
custom_headers array No 프로젝트 웹훅의 커스텀 헤더.
custom_webhook_template string No 프로젝트 웹훅의 커스텀 웹훅 템플릿.
description string No 프로젝트 웹훅 설명.
confidential_issues_events boolean No 비밀 이슈 이벤트 시 프로젝트 웹훅 트리거.
confidential_note_events boolean No 비밀 노트 이벤트 시 프로젝트 웹훅 트리거.
deployment_events boolean No 배포 이벤트 시 프로젝트 웹훅 트리거.
enable_ssl_verification boolean No 훅 트리거 시 SSL 검증 활성화.
feature_flag_events boolean No 기능 플래그 이벤트 시 프로젝트 웹훅 트리거.
issues_events boolean No 이슈 이벤트 시 프로젝트 웹훅 트리거.
job_events boolean No job 이벤트 시 프로젝트 웹훅 트리거.
merge_requests_events boolean No 머지 리퀘스트 이벤트 시 프로젝트 웹훅 트리거.
milestone_events boolean No 마일스톤 이벤트 시 프로젝트 웹훅 트리거.
name string No 프로젝트 웹훅 이름.
note_events boolean No 노트 이벤트 시 프로젝트 웹훅 트리거.
pipeline_events boolean No 파이프라인 이벤트 시 프로젝트 웹훅 트리거.
push_events boolean No 푸시 이벤트 시 프로젝트 웹훅 트리거.
push_events_branch_filter string No 일치하는 브랜치의 푸시 이벤트에만 프로젝트 웹훅 트리거.
releases_events boolean No 릴리스 이벤트 시 프로젝트 웹훅 트리거.
resource_access_token_events boolean No 프로젝트 액세스 토큰 만료 이벤트 시 프로젝트 웹훅 트리거.
signing_token string No webhook-signature 헤더를 계산하는 데 사용되는 HMAC 서명 토큰. 32바이트 키를 인코딩하는 whsec_ 형식이어야 합니다. 응답에 반환되지 않습니다.
tag_push_events boolean No 태그 푸시 이벤트 시 프로젝트 웹훅 트리거.
token string No 수신된 페이로드를 검증하기 위한 시크릿 토큰. 응답에 반환되지 않습니다. 웹훅 URL을 변경하면 시크릿 토큰이 초기화되며 유지되지 않습니다.
wiki_page_events boolean No 위키 페이지 이벤트 시 프로젝트 웹훅 트리거.
resource_deploy_token_events boolean No 프로젝트 배포 토큰 만료 이벤트 시 프로젝트 웹훅 트리거.

프로젝트 웹훅 삭제#

프로젝트에서 웹훅을 제거합니다. 이 메서드는 멱등성이 있으며 여러 번 호출할 수 있습니다. 프로젝트 웹훅이 존재하거나 존재하지 않거나 둘 중 하나입니다.

DELETE /projects/:id/hooks/:hook_id

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.

JSON 응답은 프로젝트 웹훅이 존재하는지 여부에 따라 다릅니다. 프로젝트 훅이 사용 가능한 경우 JSON 응답으로 반환되거나 빈 응답이 반환됩니다.

테스트 프로젝트 웹훅 트리거#

History

  • GitLab 16.11에서 도입됨.

  • GitLab 17.0에서 특별 속도 제한이 web_hook_test_api_endpoint_rate_limit라는 이름의 플래그와 함께 도입됨. 기본적으로 활성화됨.

지정된 프로젝트에 대한 테스트 프로젝트 웹훅을 트리거합니다.

GitLab 17.0 이상에서 이 엔드포인트에는 특별 속도 제한이 있습니다:

  • GitLab 17.0에서는 각 프로젝트 웹훅에 대해 분당 3회 요청이었습니다.

  • GitLab 17.1에서는 각 프로젝트 및 인증된 사용자에 대해 분당 5회 요청으로 변경되었습니다.

GitLab Self-Managed 및 GitLab Dedicated에서 이 제한을 비활성화하려면 관리자가 web_hook_test_api_endpoint_rate_limit라는 이름의 기능 플래그를 비활성화할 수 있습니다.

POST /projects/:id/hooks/:hook_id/test/:trigger

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
trigger string Yes push_events, tag_push_events, issues_events, confidential_issues_events, note_events, merge_requests_events, job_events, pipeline_events, wiki_page_events, releases_events, milestone_events, emoji_events, resource_access_token_events 또는 resource_deploy_token_events 중 하나.

응답 예시:

{"message":"201 Created"}

커스텀 헤더 설정#

History

PUT /projects/:id/hooks/:hook_id/custom_headers/:key

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
key string Yes 커스텀 헤더의 키.
value string Yes 커스텀 헤더의 값.

성공 시 이 엔드포인트는 응답 코드 204 No Content를 반환합니다.

커스텀 헤더 삭제#

History

DELETE /projects/:id/hooks/:hook_id/custom_headers/:key

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
key string Yes 커스텀 헤더의 키.

성공 시 이 엔드포인트는 응답 코드 204 No Content를 반환합니다.

URL 변수 설정#

PUT /projects/:id/hooks/:hook_id/url_variables/:key

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
key string Yes URL 변수의 키.
value string Yes URL 변수의 값.

성공 시 이 엔드포인트는 응답 코드 204 No Content를 반환합니다.

URL 변수 삭제#

DELETE /projects/:id/hooks/:hook_id/url_variables/:key

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
key string Yes URL 변수의 키.

성공 시 이 엔드포인트는 응답 코드 204 No Content를 반환합니다.

프로젝트 웹훅 API

GitLab v19.2
원문 보기
요약

- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated 이 API를 사용하여 프로젝트 웹훅을 관리합니다. GitLab 17.1에서 name 및 description 속성이 도입됨.

  - 
  Tier: Free, Premium, Ultimate

- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

이 API를 사용하여 프로젝트 웹훅을 관리합니다. 프로젝트 웹훅은 전체 인스턴스에 영향을 미치는 시스템 훅 및 그룹의 모든 프로젝트와 하위 그룹에 영향을 미치는 그룹 웹훅과 다릅니다.

사전 요건:

  • 프로젝트에 대한 관리자 권한이 있거나 Maintainer 또는 Owner 권한이 있어야 합니다.

프로젝트의 웹훅 목록 조회#

프로젝트 웹훅 목록을 가져옵니다.

GET /projects/:id/hooks

지원되는 속성:

속성 유형 필수 설명
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.

프로젝트 웹훅 조회#

History

  • GitLab 17.1에서 namedescription 속성이 도입됨.

  • GitLab 19.0에서 token_presentsigning_token_present 속성이 도입됨.

프로젝트의 지정된 웹훅을 조회합니다.

GET /projects/:id/hooks/:hook_id

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.

응답 예시:

{
  "id": 1,
  "url": "http://example.com/hook",
  "name": "Hook name",
  "description": "Hook description",
  "project_id": 3,
  "push_events": true,
  "push_events_branch_filter": "",
  "issues_events": true,
  "confidential_issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "confidential_note_events": true,
  "job_events": true,
  "pipeline_events": true,
  "wiki_page_events": true,
  "deployment_events": true,
  "releases_events": true,
  "milestone_events": true,
  "feature_flag_events": true,
  "enable_ssl_verification": true,
  "repository_update_events": false,
  "alert_status": "executable",
  "disabled_until": null,
  "url_variables": [ ],
  "created_at": "2012-10-12T17:04:47Z",
  "resource_access_token_events": true,
  "custom_webhook_template": "{\"event\":\"{{object_kind}}\"}",
  "custom_headers": [
    {
      "key": "Authorization"
    }
  ],
  "token_present": false,
  "signing_token_present": false
}

프로젝트 웹훅 이벤트 목록 조회#

History

시작 날짜로부터 최근 7일간 지정된 프로젝트 웹훅의 모든 이벤트를 나열합니다.

GET /projects/:id/hooks/:hook_id/events

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
status integer or string No 이벤트의 응답 상태 코드. 예: 200 또는 500. 상태 카테고리별로 검색 가능: successful (200-299), client_failure (400-499), server_failure (500-599).
page integer No 조회할 페이지. 기본값은 1.
per_page integer No 페이지당 반환할 레코드 수. 기본값은 20.

응답 예시:

[
  {
    "id": 1,
    "url": "https://example.net/",
    "trigger": "push_hooks",
    "request_headers": {
      "Content-Type": "application/json",
      "User-Agent": "GitLab/17.1.0-pre",
      "Idempotency-Key": "3a427872-00df-429c-9bc9-a9475de2efe4",
      "X-Gitlab-Event": "Push Hook",
      "X-Gitlab-Webhook-UUID": "3c5c0404-c866-44bc-a5f6-452bb1bfc76e",
      "X-Gitlab-Instance": "https://gitlab.example.com",
      "X-Gitlab-Event-UUID": "9cebe914-4827-408f-b014-cfa23a47a35f",
      "X-Gitlab-Token": "[REDACTED]"
    },
    "request_data": {
      "object_kind": "push",
      "event_name": "push",
      "before": "468abc807a2b2572f43e72c743b76cee6db24025",
      "after": "f15b32277d2c55c6c595845a87109b09c913c556",
      "ref": "refs/heads/master",
      "ref_protected": true,
      "checkout_sha": "f15b32277d2c55c6c595845a87109b09c913c556",
      "message": null,
      "user_id": 1,
      "user_name": "Administrator",
      "user_username": "root",
      "user_email": null,
      "user_avatar": "https://www.gravatar.com/avatar/13efe0d4559475ba84ecc802061febbdea6e224fcbffd7ec7da9cd431845299c?s=80&d=identicon",
      "project_id": 7,
      "project": {
        "id": 7,
        "name": "Flight",
        "description": "Incidunt ea ab officia a veniam.",
        "web_url": "https://gitlab.example.com/flightjs/Flight",
        "avatar_url": null,
        "git_ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "git_http_url": "https://gitlab.example.com/flightjs/Flight.git",
        "namespace": "Flightjs",
        "visibility_level": 10,
        "path_with_namespace": "flightjs/Flight",
        "default_branch": "master",
        "ci_config_path": null,
        "homepage": "https://gitlab.example.com/flightjs/Flight",
        "url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "http_url": "https://gitlab.example.com/flightjs/Flight.git"
      },
      "commits": [
        {
          "id": "f15b32277d2c55c6c595845a87109b09c913c556",
          "message": "v1.5.2\n",
          "title": "v1.5.2",
          "timestamp": "2017-06-19T14:39:53-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/f15b32277d2c55c6c595845a87109b09c913c556",
          "author": {
            "name": "Andrew Lunny",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        },
        {
          "id": "8749d49930866a4871fa086adbd7d2057fcc3ebb",
          "message": "Merge pull request #378 from flightjs/alunny/publish_lib\n\npublish lib and index to npm",
          "title": "Merge pull request #378 from flightjs/alunny/publish_lib",
          "timestamp": "2017-06-16T10:26:39-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/8749d49930866a4871fa086adbd7d2057fcc3ebb",
          "author": {
            "name": "angus croll",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        },
        {
          "id": "468abc807a2b2572f43e72c743b76cee6db24025",
          "message": "publish lib and index to npm\n",
          "title": "publish lib and index to npm",
          "timestamp": "2017-06-16T10:23:04-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/468abc807a2b2572f43e72c743b76cee6db24025",
          "author": {
            "name": "Andrew Lunny",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        }
      ],
      "total_commits_count": 3,
      "push_options": {},
      "repository": {
        "name": "Flight",
        "url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "description": "Incidunt ea ab officia a veniam.",
        "homepage": "https://gitlab.example.com/flightjs/Flight",
        "git_http_url": "https://gitlab.example.com/flightjs/Flight.git",
        "git_ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "visibility_level": 10
      }
    },
    "response_headers": {
      "Date": "Sun, 26 May 2024 03:03:17 GMT",
      "Content-Type": "application/json; charset=utf-8",
      "Content-Length": "16",
      "Connection": "close",
      "X-Powered-By": "Express",
      "Access-Control-Allow-Origin": "*",
      "X-Pd-Status": "sent to primary"
    },
    "response_body": "{\"success\":true}",
    "execution_duration": 1.0906479999999874,
    "response_status": "200"
  },
  {
    "id": 2,
    "url": "https://example.net/",
    "trigger": "push_hooks",
    "request_headers": {
      "Content-Type": "application/json",
      "User-Agent": "GitLab/17.1.0-pre",
      "Idempotency-Key": "7c6e0583-49f2-4dc5-a50b-4c0bcf3c1b27",
      "X-Gitlab-Event": "Push Hook",
      "X-Gitlab-Webhook-UUID": "a753eedb-1d72-4549-9ca7-eac8ea8e50dd",
      "X-Gitlab-Instance": "https://gitlab.example.com",
      "X-Gitlab-Event-UUID": "842d7c3e-3114-4396-8a95-66c084d53cb1",
      "X-Gitlab-Token": "[REDACTED]"
    },
    "request_data": {
      "object_kind": "push",
      "event_name": "push",
      "before": "468abc807a2b2572f43e72c743b76cee6db24025",
      "after": "f15b32277d2c55c6c595845a87109b09c913c556",
      "ref": "refs/heads/master",
      "ref_protected": true,
      "checkout_sha": "f15b32277d2c55c6c595845a87109b09c913c556",
      "message": null,
      "user_id": 1,
      "user_name": "Administrator",
      "user_username": "root",
      "user_email": null,
      "user_avatar": "https://www.gravatar.com/avatar/13efe0d4559475ba84ecc802061febbdea6e224fcbffd7ec7da9cd431845299c?s=80&d=identicon",
      "project_id": 7,
      "project": {
        "id": 7,
        "name": "Flight",
        "description": "Incidunt ea ab officia a veniam.",
        "web_url": "https://gitlab.example.com/flightjs/Flight",
        "avatar_url": null,
        "git_ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "git_http_url": "https://gitlab.example.com/flightjs/Flight.git",
        "namespace": "Flightjs",
        "visibility_level": 10,
        "path_with_namespace": "flightjs/Flight",
        "default_branch": "master",
        "ci_config_path": null,
        "homepage": "https://gitlab.example.com/flightjs/Flight",
        "url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "http_url": "https://gitlab.example.com/flightjs/Flight.git"
      },
      "commits": [
        {
          "id": "f15b32277d2c55c6c595845a87109b09c913c556",
          "message": "v1.5.2\n",
          "title": "v1.5.2",
          "timestamp": "2017-06-19T14:39:53-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/f15b32277d2c55c6c595845a87109b09c913c556",
          "author": {
            "name": "Andrew Lunny",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        },
        {
          "id": "8749d49930866a4871fa086adbd7d2057fcc3ebb",
          "message": "Merge pull request #378 from flightjs/alunny/publish_lib\n\npublish lib and index to npm",
          "title": "Merge pull request #378 from flightjs/alunny/publish_lib",
          "timestamp": "2017-06-16T10:26:39-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/8749d49930866a4871fa086adbd7d2057fcc3ebb",
          "author": {
            "name": "angus croll",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        },
        {
          "id": "468abc807a2b2572f43e72c743b76cee6db24025",
          "message": "publish lib and index to npm\n",
          "title": "publish lib and index to npm",
          "timestamp": "2017-06-16T10:23:04-07:00",
          "url": "https://gitlab.example.com/flightjs/Flight/-/commit/468abc807a2b2572f43e72c743b76cee6db24025",
          "author": {
            "name": "Andrew Lunny",
            "email": "[REDACTED]"
          },
          "added": [],
          "modified": [
            "package.json"
          ],
          "removed": []
        }
      ],
      "total_commits_count": 3,
      "push_options": {},
      "repository": {
        "name": "Flight",
        "url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "description": "Incidunt ea ab officia a veniam.",
        "homepage": "https://gitlab.example.com/flightjs/Flight",
        "git_http_url": "https://gitlab.example.com/flightjs/Flight.git",
        "git_ssh_url": "ssh://git@gitlab.example.com:2222/flightjs/Flight.git",
        "visibility_level": 10
      }
    },
    "response_headers": {
      "Date": "Sun, 26 May 2024 03:03:19 GMT",
      "Content-Type": "application/json; charset=utf-8",
      "Content-Length": "16",
      "Connection": "close",
      "X-Powered-By": "Express",
      "Access-Control-Allow-Origin": "*",
      "X-Pd-Status": "sent to primary"
    },
    "response_body": "{\"success\":true}",
    "execution_duration": 1.0716120000000728,
    "response_status": "200"
  }
]

프로젝트 웹훅 이벤트 재전송#

History

특정 프로젝트 웹훅 이벤트를 재전송합니다.

이 엔드포인트에는 각 프로젝트 웹훅 및 인증된 사용자에 대해 분당 5회 요청의 속도 제한이 있습니다. GitLab Self-Managed 및 GitLab Dedicated에서 이 제한을 비활성화하려면 관리자가 web_hook_event_resend_api_endpoint_rate_limit라는 이름의 기능 플래그를 비활성화할 수 있습니다.

POST /projects/:id/hooks/:hook_id/events/:hook_event_id/resend

지원되는 속성:

속성 유형 필수 설명
hook_event_id integer Yes 프로젝트 웹훅 이벤트의 ID.
hook_id integer Yes 프로젝트 웹훅의 ID.

응답 예시:

{
  "response_status": 200
}

프로젝트에 웹훅 추가#

History

  • GitLab 17.1에서 namedescription 속성이 도입됨.

  • GitLab 19.0에서 signing_token 속성이 webhook_signing_token이라는 이름의 플래그와 함께 도입됨. 기본적으로 활성화됨.

  • GitLab 19.1에서 기능 플래그 webhook_signing_token제거됨.

지정된 프로젝트에 웹훅을 추가합니다.

POST /projects/:id/hooks

지원되는 속성:

속성 유형 필수 설명
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
url string Yes 프로젝트 웹훅 URL.
branch_filter_strategy string No 브랜치별로 푸시 이벤트를 필터링합니다. 가능한 값: wildcard (기본값), regex, all_branches.
confidential_issues_events boolean No 비밀 이슈 이벤트 시 프로젝트 웹훅 트리거.
confidential_note_events boolean No 비밀 노트 이벤트 시 프로젝트 웹훅 트리거.
custom_headers array No 프로젝트 웹훅의 커스텀 헤더.
custom_webhook_template string No 프로젝트 웹훅의 커스텀 웹훅 템플릿.
deployment_events boolean No 배포 이벤트 시 프로젝트 웹훅 트리거.
description string No 웹훅 설명.
enable_ssl_verification boolean No 웹훅 트리거 시 SSL 검증 활성화.
feature_flag_events boolean No 기능 플래그 이벤트 시 프로젝트 웹훅 트리거.
issues_events boolean No 이슈 이벤트 시 프로젝트 웹훅 트리거.
job_events boolean No job 이벤트 시 프로젝트 웹훅 트리거.
merge_requests_events boolean No 머지 리퀘스트 이벤트 시 프로젝트 웹훅 트리거.
milestone_events boolean No 마일스톤 이벤트 시 프로젝트 웹훅 트리거.
name string No 프로젝트 웹훅 이름.
note_events boolean No 노트 이벤트 시 프로젝트 웹훅 트리거.
pipeline_events boolean No 파이프라인 이벤트 시 프로젝트 웹훅 트리거.
push_events boolean No 푸시 이벤트 시 프로젝트 웹훅 트리거.
push_events_branch_filter string No 일치하는 브랜치의 푸시 이벤트에만 프로젝트 웹훅 트리거.
releases_events boolean No 릴리스 이벤트 시 프로젝트 웹훅 트리거.
resource_access_token_events boolean No 프로젝트 액세스 토큰 만료 이벤트 시 프로젝트 웹훅 트리거.
signing_token string No webhook-signature 헤더를 계산하는 데 사용되는 HMAC 서명 토큰. 32바이트 키를 인코딩하는 whsec_ 형식이어야 합니다. 응답에 반환되지 않습니다.
tag_push_events boolean No 태그 푸시 이벤트 시 프로젝트 웹훅 트리거.
token string No 수신된 페이로드를 검증하기 위한 시크릿 토큰. 응답에 반환되지 않습니다.
wiki_page_events boolean No 위키 이벤트 시 프로젝트 웹훅 트리거.
resource_deploy_token_events boolean No 프로젝트 배포 토큰 만료 이벤트 시 프로젝트 웹훅 트리거.

프로젝트 웹훅 업데이트#

History

  • GitLab 17.1에서 namedescription 속성이 도입됨.

  • GitLab 19.0에서 signing_token 속성이 webhook_signing_token이라는 이름의 플래그와 함께 도입됨. 기본적으로 활성화됨.

  • GitLab 19.1에서 기능 플래그 webhook_signing_token제거됨.

지정된 프로젝트의 프로젝트 웹훅을 업데이트합니다.

PUT /projects/:id/hooks/:hook_id

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
url string Yes 프로젝트 웹훅 URL.
branch_filter_strategy string No 브랜치별로 푸시 이벤트를 필터링합니다. 가능한 값: wildcard (기본값), regex, all_branches.
custom_headers array No 프로젝트 웹훅의 커스텀 헤더.
custom_webhook_template string No 프로젝트 웹훅의 커스텀 웹훅 템플릿.
description string No 프로젝트 웹훅 설명.
confidential_issues_events boolean No 비밀 이슈 이벤트 시 프로젝트 웹훅 트리거.
confidential_note_events boolean No 비밀 노트 이벤트 시 프로젝트 웹훅 트리거.
deployment_events boolean No 배포 이벤트 시 프로젝트 웹훅 트리거.
enable_ssl_verification boolean No 훅 트리거 시 SSL 검증 활성화.
feature_flag_events boolean No 기능 플래그 이벤트 시 프로젝트 웹훅 트리거.
issues_events boolean No 이슈 이벤트 시 프로젝트 웹훅 트리거.
job_events boolean No job 이벤트 시 프로젝트 웹훅 트리거.
merge_requests_events boolean No 머지 리퀘스트 이벤트 시 프로젝트 웹훅 트리거.
milestone_events boolean No 마일스톤 이벤트 시 프로젝트 웹훅 트리거.
name string No 프로젝트 웹훅 이름.
note_events boolean No 노트 이벤트 시 프로젝트 웹훅 트리거.
pipeline_events boolean No 파이프라인 이벤트 시 프로젝트 웹훅 트리거.
push_events boolean No 푸시 이벤트 시 프로젝트 웹훅 트리거.
push_events_branch_filter string No 일치하는 브랜치의 푸시 이벤트에만 프로젝트 웹훅 트리거.
releases_events boolean No 릴리스 이벤트 시 프로젝트 웹훅 트리거.
resource_access_token_events boolean No 프로젝트 액세스 토큰 만료 이벤트 시 프로젝트 웹훅 트리거.
signing_token string No webhook-signature 헤더를 계산하는 데 사용되는 HMAC 서명 토큰. 32바이트 키를 인코딩하는 whsec_ 형식이어야 합니다. 응답에 반환되지 않습니다.
tag_push_events boolean No 태그 푸시 이벤트 시 프로젝트 웹훅 트리거.
token string No 수신된 페이로드를 검증하기 위한 시크릿 토큰. 응답에 반환되지 않습니다. 웹훅 URL을 변경하면 시크릿 토큰이 초기화되며 유지되지 않습니다.
wiki_page_events boolean No 위키 페이지 이벤트 시 프로젝트 웹훅 트리거.
resource_deploy_token_events boolean No 프로젝트 배포 토큰 만료 이벤트 시 프로젝트 웹훅 트리거.

프로젝트 웹훅 삭제#

프로젝트에서 웹훅을 제거합니다. 이 메서드는 멱등성이 있으며 여러 번 호출할 수 있습니다. 프로젝트 웹훅이 존재하거나 존재하지 않거나 둘 중 하나입니다.

DELETE /projects/:id/hooks/:hook_id

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.

JSON 응답은 프로젝트 웹훅이 존재하는지 여부에 따라 다릅니다. 프로젝트 훅이 사용 가능한 경우 JSON 응답으로 반환되거나 빈 응답이 반환됩니다.

테스트 프로젝트 웹훅 트리거#

History

  • GitLab 16.11에서 도입됨.

  • GitLab 17.0에서 특별 속도 제한이 web_hook_test_api_endpoint_rate_limit라는 이름의 플래그와 함께 도입됨. 기본적으로 활성화됨.

지정된 프로젝트에 대한 테스트 프로젝트 웹훅을 트리거합니다.

GitLab 17.0 이상에서 이 엔드포인트에는 특별 속도 제한이 있습니다:

  • GitLab 17.0에서는 각 프로젝트 웹훅에 대해 분당 3회 요청이었습니다.

  • GitLab 17.1에서는 각 프로젝트 및 인증된 사용자에 대해 분당 5회 요청으로 변경되었습니다.

GitLab Self-Managed 및 GitLab Dedicated에서 이 제한을 비활성화하려면 관리자가 web_hook_test_api_endpoint_rate_limit라는 이름의 기능 플래그를 비활성화할 수 있습니다.

POST /projects/:id/hooks/:hook_id/test/:trigger

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
trigger string Yes push_events, tag_push_events, issues_events, confidential_issues_events, note_events, merge_requests_events, job_events, pipeline_events, wiki_page_events, releases_events, milestone_events, emoji_events, resource_access_token_events 또는 resource_deploy_token_events 중 하나.

응답 예시:

{"message":"201 Created"}

커스텀 헤더 설정#

History

PUT /projects/:id/hooks/:hook_id/custom_headers/:key

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
key string Yes 커스텀 헤더의 키.
value string Yes 커스텀 헤더의 값.

성공 시 이 엔드포인트는 응답 코드 204 No Content를 반환합니다.

커스텀 헤더 삭제#

History

DELETE /projects/:id/hooks/:hook_id/custom_headers/:key

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
key string Yes 커스텀 헤더의 키.

성공 시 이 엔드포인트는 응답 코드 204 No Content를 반환합니다.

URL 변수 설정#

PUT /projects/:id/hooks/:hook_id/url_variables/:key

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
key string Yes URL 변수의 키.
value string Yes URL 변수의 값.

성공 시 이 엔드포인트는 응답 코드 204 No Content를 반환합니다.

URL 변수 삭제#

DELETE /projects/:id/hooks/:hook_id/url_variables/:key

지원되는 속성:

속성 유형 필수 설명
hook_id integer Yes 프로젝트 웹훅의 ID.
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
key string Yes URL 변수의 키.

성공 시 이 엔드포인트는 응답 코드 204 No Content를 반환합니다.