ウェブフックイベントリスト

Prev Next

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

ウェブフックに登録できるイベントは次の通りです。

参考
  • イベントタイプを選択すると、その下位にあるアクションは全て検知されます。
  • イベントタイプの下位アクションごとに選択できません。
注意

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

イベントタイプ 内容 下位アクション アクション実行方法の参考資料
push 1つ以上のコミットがリポジトリに push
  • commit: コミット
Gitクライアントを使用する
pull_request Pull Requestタスク
  • opened : Pull Request作成時に発生
  • closed : Pull Requestを閉じると発生
  • merged : Pull Requestマージ時に発生
  • edited : Pull Request変更時に発生
  • updated_head : Pull Request from branchの HEADが変わる場合に発生
リポジトリ管理 - フルリクエストを使用
create ブランチやタグを作成
  • created: 作成
リポジトリ管理 - ブランチ管理
delete ブランチやタグを削除
  • deleted: 削除
リポジトリ管理 - ブランチ管理
meta ウェブフック削除 N/A ウェブフックを使用する - ウェブフック削除
repository リポジトリプロパティの変更
  • edited : リポジトリの説明、file safer使用有無プロパティ変更時に発生
リポジトリ管理 - リポジトリ設定変更
file_safer File Saferマルウェアスキャン完了
  • done : File Saferスキャンが完了すると発生
File Saferのマルウェアスキャン
file_lock (LFS) file lockを使用する
  • create : lfs file lock使用時に発生
  • delete : lfs file unlock使用時に発生
ファイルロック

ウェブフック Payloadの構成

ウェブフック Payloadは、ウェブフック呼び出し時に渡される実際のデータです。

注意
  • Payloadデータサイズが65,535byteより大きい場合、正常な Webhookの呼び出しは不可能です。
  • Content Typeが application/x-www-form-urlencodedに設定されている場合、request body内の「payload」 keyに対応する valueとして Payloadデータ全体が転送されます。

ウェブフック Payloadの形式

ウェブフック Payload構成の形式は次の通りです。
event keyに対応する部分はイベントタイプによって変わり、残りの versionrepositorysendertimestampは一定の形式を持ちます。

{
    "version": <ウェブフックバージョン>,
    "repository": {
        "id": <リポジトリ id>,
        "name": <リポジトリ名>,
        "description": <リポジトリの説明>,
        "ssh_url": <リポジトリ git sshのアドレス>,
        "https_url": <リポジトリ git httpsのアドレス>,
        "portaladdr": <リポジトリポータルのアドレス>
        "created_at": <作成日>,
        "owner": <作成者>
    },
    "sender": <送信者の情報>,
    "event": {
        "type": <イベントタイプ>
        "payload": <イベント情報>
    },
    "timestamp": <時間情報>
}
キー タイプ 説明 備考
version string SourceCommitのウェブフックバージョン 現在のウェブフック最新バージョンは、「v1」
repository.id number リポジトリ id値
repository.name string リポジトリ名
repository.description string リポジトリの説明
repository.ssh_url string リポジトリ git sshのアドレス
repository.https_url string リポジトリ git httpsのアドレス
repository.portaladdr string リポジトリポータルのアドレス
repository.created_at number リポジトリの作成日 timestamp
repository.owner string リポジトリを作成したユーザー
sender object 送信者の情報 参照: 送信者情報の形式
event.type string イベントタイプ 参照: ウェブフックイベント
event.payload object イベント情報 参照: イベントごとの詳細情報
timestamp number ウェブフック発生時間 unix timestamp

送信者情報の形式

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

  • https 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",
    }
    
キー タイプ 説明 備考
mbrNo string 顧客ナンバー
id_no string 顧客識別値
user_id string ユーザー 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>
            }
        ]
    }
}
キー タイプ 説明 備考
type string イベントタイプ "push"
payload.ref string push対象の ref情報
payload.action string 下位アクション "commit"
payload.before string 以前の sha値
payload.after string 以後の sha値
payload.sender object 送信者情報
  • 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_commit array pushされたコミットの head commit
payload.head_commit[*].hash_id string commitの hash_id
payload.head_commit[*].tree_id string commitの tree_id
payload.head_commit[*].parent_hash_id string commitの parent_hash_id
payload.head_commit[*].timestamp string commitの timestamp
payload.head_commit[*].author.author_name string commitの author_name
payload.head_commit[*].committer.committer_name string commitの committer_name
payload.commits array pushされた commitリスト 一番最新のコミットが0番のインデックスから開始
payload.commits[*].commit_message string commitの commit_message
payload.commits[*].hash_id string commitの hash_id
payload.commits[*].tree_id string commitの tree_id
payload.commits[*].parent_hash_id string commitの parent_hash_id
payload.commits[*].timestamp string commitの timestamp
payload.commits[*].author.author_name string commitの author_name
payload.commits[*].committer.committer_name string commitの committer_name
payload.commits[*].commit_message string commitの 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>
            }
        ]
    }
}
キー タイプ 説明 備考
type string イベントタイプ "create"
payload.ref string push対象の ref情報
payload.type string 作成対象タイプ "branch" or "tag"
payload.action string 下位アクション "created"
payload.before string 以前の sha値
payload.after string 以後の sha値
payload.sender object 送信者の情報
  • 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_commit array pushされたコミットの head commit
payload.head_commit[*].hash_id string commitの hash_id
payload.head_commit[*].tree_id string commitの tree_id
payload.head_commit[*].parent_hash_id string commitの parent_hash_id
payload.head_commit[*].timestamp string commitの timestamp
payload.head_commit[*].author.author_name string commitの author_name
payload.head_commit[*].committer.committer_name string commitの 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>
            }
        ]
    }
}
キー タイプ 説明 備考
type string イベントタイプ "delete"
payload.ref string push対象の ref情報
payload.type string 作成対象タイプ "branch" or "tag"
payload.action string 下位アクション "deleted"
payload.before string 以前の sha値
payload.after string 以後の sha値
payload.sender object 送信者の情報
  • 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_commit array pushされたコミットの head commit
payload.head_commit[*].hash_id string commitの hash_id
payload.head_commit[*].tree_id string commitの tree_id
payload.head_commit[*].parent_hash_id string commitの parent_hash_id
payload.head_commit[*].timestamp string commitの timestamp
payload.head_commit[*].author.author_name string commitの author_name
payload.head_commit[*].committer.committer_name string commitの 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>
        },
    }
}
キー タイプ 説明 備考
type string イベントタイプ "pull_request"
payload.action string 下位アクション
  • opened: 新規 pull requestが作成された場合
  • closed: pull requestが閉ざされた場合
  • merged: pull requestがマージされた場合
  • edited: pull requestの title、descriptionが変更された場合
  • updated_head: pull requestの from branchに pushが発生した場合
payload.pull_request_number number フルリクエストのナンバー
payload.pull_request_title string フルリクエストのタイトル
payload.pull_request_description. string フルリクエストの説明
payload.auto_merge_enable boolean 競合なしでマージできるかどうか payload.actionが「opened」と「updated_head」の場合のみに提供
from.branch string fromブランチの名前
from.sha string fromブランチの sha値
to.branch string toブランチの名前
to.sha string toブランチの sha値
sender.user_id string ユーザー id値

metaイベントの詳細説明と例

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

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
        }
    }
}
キー タイプ 説明 備考
type string イベントタイプ "repository"
payload.action string 下位アクション "edited"
payload.sender.user_id string ユーザー id
payload.before.description string 変更前のリポジトリの説明
payload.before.file_safer boolean 変更前の file safer使用有無
payload.after.description string 変更後のリポジトリの説明
payload.after.file_safer boolean 変更後の 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"
    }
}
キー タイプ 説明 備考
type string イベントタイプ "file_safer"
payload.target_hash string ターゲットハッシュ値
payload.action string 下位アクション done
payload.total_file_count number スキャンファイル数の合計
payload.infected_file_count number マルウェアファイル数の合計
payload.request_date string ファイルスキャンリクエスト時間
payload.complete_date string ファイルスキャン完了時間

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"
    }
}
キー タイプ 説明 備考
type string イベントタイプ "file_lock"
payload.action string 下位アクション
  • create: ファイル lockを使用する場合
  • delete: ファイル unlockを使用する場合
payload.sender.user_id string ユーザー id
path string ファイルパス
locked_time string lockが行われた時間 actionが createの場合のみに提供
unlocked_time string unlockが行われた時間 actionが deleteの場合のみに提供