Webフックイベントリスト
    • PDF

    Webフックイベントリスト

    • PDF

    Article Summary

    Classic/VPC環境で利用できます。

    Webフックに登録できるイベントは以下の通りです。

    参考
    • イベントタイプを選択すると、サブアクションはすべて検出されます。
    • イベントタイプのサブアクションごとに選択できません。
    注意

    新規ブランチを作成した場合は、createイベントのみ発生し、pushイベントは発生しません。

    イベントタイプ内容下位アクションアクション実行方法参考資料
    push1つ以上のコミットがリポジトリに push
    • commit: コミット
    Gitクライアントを使用する
    pull_requestPull Request作業
    • opened : Pull Request 作成時発生
    • closed : Pull Request 閉じる時に発生
    • merged : Pull Request 併合時に発生
    • edited : Pull Request 修正時に発生
    • updated_head : Pull Request from branchの HEADが変更する場合に発生
    リポジトリ管理 - プルリクエストの使用
    createブランチまたはタグの作成
    • created: 作成
    リポジトリ管理 - ブランチ管理
    deleteブランチまたはタグの削除
    • deleted: 削除
    リポジトリ管理 - ブランチ管理
    metaWebフックの削除N/AWebフックの使用 - Webフックの削除
    repositoryリポジトリの属性変更
    • edited: リポジトリの説明、file safer使用有無属性の編集時に発生
    リポジトリ管理 - リポジトリ設定変更
    file_saferFile Safer悪性コード検査完了
    • done: File Safer検査が完了した場合に発生
    File Safer悪性コード検査
    file_lock(LFS)file lockを使用
    • create : lfs file lock使用時に発生
    • delete : lfs file unlock使用時に発生
    ファイルロック

    Webフック Payload構成

    Webフック Payloadは、Webフック呼び出し時に伝達される実質的なデータです。

    注意
    • Payloadデータサイズが 65,535byteを超過する場合、正常な Webhook呼び出しができません。
    • Content Typeが application/x-www-form-urlencodedに設定されている場合、request body内の'payload'keyに該当する valueに全体 Payloadデータが送信されます。

    Webフック Payload形式

    Webフック Payload構成形式は以下の通りです。event キーに該当する部分はイベントタイプによって異なり、その他の version, repository, sender, timestampは一定の形式です。

    {
        "version": <Webフックバージョン>,
        "repository": {
            "id": <リポジトリ id>,
            "name": <リポジトリ名>,
            "description": <リポジトリの説明>,
            "ssh_url": <リポジトリ git sshアドレス>,
            "https_url": <リポジトリ git httpsアドレス>,
            "portaladdr": <リポジトリポータルアドレス>
            "created_at": <作成日>,
            "owner": <作成者>
        },
        "sender": <送信者情報>,
        "event": {
            "type": <イベントタイプ>
            "payload": <イベント情報>
        },
        "timestamp": <時間情報>
    }
    
    キータイプ説明備考
    versionstringSourceCommit Webフックバージョン現在の Webフックの最新バージョンは「v1」
    repository.idnumberリポジトリ id値
    repository.namestringリポジトリ名
    repository.descriptionstringリポジトリの説明
    repository.ssh_urlstringリポジトリ git sshアドレス
    repository.https_urlstringリポジトリ git httpアドレス
    repository.portaladdrstringリポジトリポータルアドレス
    repository.created_atnumberリポジトリ作成日timestamp
    repository.ownerstringリポジトリを作成したユーザー
    senderobject送信者情報参照: 送信者情報形式
    event.typestringイベントタイプ参照: Webフックイベント
    event.payloadobjectイベント情報参照: イベント別詳細
    timestampnumberWebフック発生時間 unix timestamp

    送信者情報形式

    送信者(sender)情報の形式は次のとおりです。

    • http gitアドレスを使用してイベントが発生した場合

      {
          "mbrNo": <member-no>,
          "user_id": <user-id>,
          "id_no" : <id-No>
      }
      
    • ssh gitアドレスを使用してイベントが発生した場合

      {
          "mbrNo": <member-no>,
          "type": "Tenant" | "SubAccount",
          "user_id" : <user-id> // Provided only in case of subaccount
      }
      
    • file_saferイベントを使用する場合

      {
        "mbrNo": <member-no>,
        "type": "system",
      }
      
    キータイプ説明備考
    mbrNostring顧客番号
    id_nostring顧客の識別値
    user_idstringユーザー id

    Payload全体例

    event.type=createである場合の例です。

    {
        "version": "v1",
        "repository": {
            "id": 123456,
            "name": "test-name",
            "description": "test-description",
            "ssh_url": "ssh://devtools.ncloud.com/test/test-repo.git",
            "https_url": "https://devtools.ncloud.com/test/test-repo.git",
            "portaladdr": "https://devtools.ncloud.com/test/test-repo",
            "created_at": 1662524215000,
            "owner": "test@sample.com"
        },
        "sender": {
            "mbrNo": "123456789",
            "id_no": "aaaaaaaaa-bbbb-cccc-dddd-eeeeeeeeee",
            "user_id": "test-user"
        },
        "timestamp": 1663208183206,
        "event": {
            "type": "create",
            "payload": {
                "ref": "refs/heads/<branch name>",
                "type": "branch",
                "name": <branch-name>,
                "action": "created",
                "before": "0000000000000000000000000000000000000000",
                "after": "ce7c990a1e8762d13e5ef0dc98e605e7c0bd75ec",
                "sender": {
                    "protocol": "https",
                    "user_id": <user id>,
                    "id_no": <id-no>
                },
                "head_commit": [
                    {
                        "hash_id": "ce7c990a1e8762d13e5ef0dc98e605e7c0bd75ec",
                        "tree_id": "b9daacb4ab18228adf369b71b02eae916a00e081",
                        "parent_hash_id": "7b287cee698ca0a0f8df15a8b6133e895ba9e9bb",
                        "timestamp": "1655899275",
                        "author": {
                            "author_name": <author name>
                        },
                        "committer": {
                            "committer_name": <committer name>
                        },
                        "commit_message": <commit message>
                    }
                ]
            }
        }
    }
    
    

    イベント別詳細情報

    イベントタイプによって変わるウェブフック Payload内の event形式について説明します。

    pushイベント詳細説明および例

    {
        "type": "push",
        "payload": {
            "ref": "refs/heads/<branch name>",
            "action": "commit",
            "before": "c3b67b4527cb196da2195082794cca1643aa7bba",
            "after":  "0eb7c3a853eb50ada35f8dc96ae796ba404d1485",
            "sender": {
                "protocol": "https",
                "user_id": <user id>,
                "id_no": <id-no>
            },
            "head_commit": [
                {   
                    "hash_id": "0eb7c3a853eb50ada35f8dc96ae796ba404d1485",
                    "tree_id": "d038fe14f2da4ac2227b982a20891a32fb8ae99c",
                    "parent_hash_id": "71e03a954a845240b1944fdc93b9606adce98cc1",
                    "timestamp": "1655899919",
                    "author": {
                        "author_name": <author name>
                    },
                    "committer": {
                        "committer_name": <committer name>
                    },
                    "commit_message": <commit message>
                }
            ],
            "commits": [
                {   
                    "hash_id": "0eb7c3a853eb50ada35f8dc96ae796ba404d1485",
                    "tree_id": "d038fe14f2da4ac2227b982a20891a32fb8ae99c",
                    "parent_hash_id": "71e03a954a845240b1944fdc93b9606adce98cc1",
                    "timestamp": "1655899919",
                    "author": {
                        "author_name": <author name>
                    },
                    "committer": {
                        "committer_name": <committer name>
                    },
                    "commit_message": <commit message>
                }
            ]
        }
    }
    
    キータイプ説明備考
    typestringイベントタイプ"push"
    payload.refstringpush対象 ref情報
    payload.actionstring下位アクション"commit"
    payload.beforestring以前の sha値
    payload.afterstring以後の sha値
    payload.senderobject送信者情報
    • ssh gitアドレスを使用した場合
      • "protocol" : "ssh"
      • "user_id" : "[Tenant Account]" or user_id"
    • https gitアドレスを使用した場合
      • "protocol" : "https"
      • "user_id" : "user_id",
      • "id_no" : "id-no"
    payload.head_commitarraypushされたコミットの head commit
    payload.head_commit[*].hash_idstringcommitの hash_id
    payload.head_commit[*].tree_idstringcommitの tree_id
    payload.head_commit[*].parent_hash_idstringcommitの parent_hash_id
    payload.head_commit[*].timestampstringcommitの timestamp
    payload.head_commit[*].author.author_namestringcommitの author_name
    payload.head_commit[*].committer.committer_namestringcommitの committer_name
    payload.commitsarraypushされた commitリスト最新のコミットメントが0番インデックスから開始
    payload.commits[*].commit_messagestringcommitの commit_message
    payload.commits[*].hash_idstringcommitの hash_id
    payload.commits[*].tree_idstringcommitの tree_id
    payload.commits[*].parent_hash_idstringcommitの parent_hash_id
    payload.commits[*].timestampstringcommitの timestamp
    payload.commits[*].author.author_namestringcommitの author_name
    payload.commits[*].committer.committer_namestringcommitの committer_name
    payload.commits[*].commit_messagestringcommitの commit_message

    createイベント詳細説明および例

    {
        "type": "create",
        "payload": {
            "ref": "refs/heads/<branch name>",
            "type": "branch",
            "name": <branch-name>,
            "action": "created",
            "before": "0000000000000000000000000000000000000000",
            "after": "ce7c990a1e8762d13e5ef0dc98e605e7c0bd75ec",
            "sender": {
                "protocol": "https",
                "user_id": <user id>,
                "id_no": <id-no>
            },
            "head_commit": [
                {
                    "hash_id": "ce7c990a1e8762d13e5ef0dc98e605e7c0bd75ec",
                    "tree_id": "b9daacb4ab18228adf369b71b02eae916a00e081",
                    "parent_hash_id": "7b287cee698ca0a0f8df15a8b6133e895ba9e9bb",
                    "timestamp": "1655899275",
                    "author": {
                        "author_name": <author name>
                    },
                    "committer": {
                        "committer_name": <committer name>
                    },
                    "commit_message": <commit message>
                }
            ]
        }
    }
    
    キータイプ説明備考
    typestringイベントタイプ"create"
    payload.refstringpush対象 ref情報
    payload.typestring配布対象のタイプ"branch" or "tag"
    payload.actionstring下位アクション"created"
    payload.beforestring以前の sha値
    payload.afterstring以後の sha値
    payload.senderobject送信者情報
    • ssh gitアドレスを使用した場合
      • "protocol" : "ssh"
      • "user_id" : "[Tenant Account] or user_id""
    • https gitアドレスを使用した場合
      • "protocol" : "https"
      • "user_id" : "user_id",
      • "id_no" : "id-no"
    payload.head_commitarraypushされたコミットの head commit
    payload.head_commit[*].hash_idstringcommitの hash_id
    payload.head_commit[*].tree_idstringcommitの tree_id
    payload.head_commit[*].parent_hash_idstringcommitの parent_hash_id
    payload.head_commit[*].timestampstringcommitの timestamp
    payload.head_commit[*].author.author_namestringcommitの author_name
    payload.head_commit[*].committer.committer_namestringcommitの committer_name

    deleteイベント詳細説明および例

    {
        "type": "delete",
        "payload": {
            "ref": "refs/heads/<branch name>",
            "type": "branch",
            "name": <branch-name>,
            "action": "deleted",
            "before": "68ed6fc3e2cdf74af0fa1b3591ff593d1e28a4cb",
            "after": "0000000000000000000000000000000000000000",
            "sender": {
                "protocol": "https",
                "user_id": <user id>,
                "id_no": <id-no>
            },
            "head_commit": [
                {
                    "hash_id": "ce7c990a1e8762d13e5ef0dc98e605e7c0bd75ec",
                    "tree_id": "b9daacb4ab18228adf369b71b02eae916a00e081",
                    "parent_hash_id": "7b287cee698ca0a0f8df15a8b6133e895ba9e9bb",
                    "timestamp": "1655899275",
                    "author": {
                        "author_name": <author name>
                    },
                    "committer": {
                        "committer_name": <committer name>
                    },
                    "commit_message": <commit message>
                }
            ]
        }
    }
    
    キータイプ説明備考
    typestringイベントタイプ"delete"
    payload.refstringpush対象 ref情報
    payload.typestring配布対象のタイプ"branch" or "tag"
    payload.actionstring下位アクション"deleted"
    payload.beforestring以前の sha値
    payload.afterstring以後の sha値
    payload.senderobject送信者情報
    payload.head_commitarraypushされたコミットの head commit
    payload.head_commit[*].hash_idstringcommitの hash_id
    payload.head_commit[*].tree_idstringcommitの tree_id
    payload.head_commit[*].parent_hash_idstringcommitの parent_hash_id
    payload.head_commit[*].timestampstringcommitの timestamp
    payload.head_commit[*].author.author_namestringcommitの author_name
    payload.head_commit[*].committer.committer_namestringcommitの committer_name

    pull_requestイベント詳細説明および例

    {
        "type": "pull_request",
        "payload": {
            "action": "opened" | "closed" | "merged" | "edited" | "updated_head",
            "pull_request_number": 10,
            "pull_request_title": <pull request name>,
            "pull_request_description": <pull request description>,
            "auto_merge_enable": true,
            "from": {
                "branch": "sub",
                "sha": <sha>
            },
            "to": {
                "branch": "master",
                "sha": <sha>
            },
            "sender": {
                "user_id": <user id>
            },
        }
    }
    
    キータイプ説明備考
    typestringイベントタイプ"pull_request"
    payload.actionstring下位アクション
    • opened: 新規 pull requestが作成された場合
    • closed: pull requestが閉じた場合
    • merged: pull requestが併合された場合
    • edited: pull requestの title , descriptionが編集された場合
    • updated_head: pull requestの from branchに pushが起こった場合
    payload.pull_request_numbernumberプルリクエストの番号
    payload.pull_request_titlestringプルリクエストの題名
    payload.pull_request_description.stringプルリクエストの説明
    payload.auto_merge_enablebooleanコンフリクトなしに併合可能かどうかpayload.actionが 「opened」と「updated_head」である場合のみ提供
    from.branchstringfromブランチ名
    from.shastringFromブランチの sha値
    to.branchstringtoブランチ名
    to.shastringtoブランチの sha値
    sender.user_idstringユーザー id値

    metaイベント詳細説明および例

    {
        "type": "meta",
        "payload": {
            "webhook": {
                "id": <webhook id>,
                "name": <webhook name>
            }
        }
    }
    
    キータイプ説明備考
    typestringイベントタイプ"meta"
    payload.webhook.idnumberwebhook id値
    payload.webhook.namestringwebhook名

    repositoryイベント詳細説明および例

    {
        "type": "repository",
        "payload": {
            "action": "edited",
            "sender": {
                "user_id": <user id>
            },
            "before": {
                "description": "before description",
                "file_safer": true
            },
            "after": {
                "description": "after description",
                "file_safer": false
            }
        }
    }
    
    キータイプ説明備考
    typestringイベントタイプ"repository"
    payload.actionstring下位アクション"edited"
    payload.sender.user_idstringユーザー id
    payload.before.descriptionstring編集前のリポジトリ説明
    payload.before.file_saferboolean編集前に file saferを使用するかどうか
    payload.after.descriptionstring編集後のリポジトリ説明
    payload.after.file_saferboolean編集後、file saferを使用するかどうか

    file_saferイベント詳細説明および例

    {
        "type": "file_safer",
        "payload": {
            "target_hash": "123456117f77a541bdcb68d36234dbb317c7f1f7",
            "action": "done",
            "total_file_count": 1,
            "infected_file_count": 0,
            "request_date": "2022-09-14T11:24:28.000Z",
            "complete_date": "2022-09-14T11:24:40.000Z"
        }
    }
    
    キータイプ説明備考
    typestringイベントタイプ"file_safer"
    payload.target_hashstringターゲットのハッシュ値
    payload.actionstring下位アクションdone
    payload.total_file_countnumberファイル総検査数
    payload.infected_file_countnumber悪性ファイルの総数
    payload.request_datestringファイル検査所要時間
    payload.complete_datestringファイル検査完了時間

    file_lockイベント詳細説明および例

    {
        "type": "file_lock",
        "payload": {
            "action": "create",
            "sender": {
                "user_id": <user id>
            },
            "path": "file.txt",
            "locked_time": "2022-01-01 00:00:00.00",
            "unlocked_time": "2022-01-01 00:00:00.00"
        }
    }
    
    キータイプ説明備考
    typestringイベントタイプ"file_lock"
    payload.actionstring下位アクション
    • create : ファイル lockを使用する場合
    • delete : ファイル unlockを使用する場合
    payload.sender.user_idstringユーザー id
    pathstringファイル経路
    locked_timestringlockが行われた時間actionが createの場合にのみ提供
    unlocked_timestringunlockが行われた時間actionが deleteの場合にのみ提供

    この記事は役に立ちましたか?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.