跳到主要内容

Commit Event

Commit事件参数说明

请求头

参数名称类型参数说明
User-Agentstring
Content-Typestring
X-GitCode-Eventstring事件类型,Push Hook代表推送事件
X-GitCode-Deliverystring请求唯一id

请求参数

参数名称参数类型参数说明
object_kindstring事件类型,此处为 "push" 表示推送事件
event_namestring事件名称,与 object_kind 相同,表示推送事件
beforestring推送前的提交 SHA 值
afterstring推送后的提交 SHA 值
refstringGit 引用路径,例如 "refs/heads/main" 表示主分支
checkout_shastring检出的提交 SHA 值
messagestring消息内容
user_idinteger触发推送事件的用户 ID
user_namestring用户的显示名称
user_usernamestring用户的用户名
user_emailstring用户的邮箱地址
user_avatarstring用户头像的 URL 地址
project_idinteger项目的唯一标识符
project.idinteger项目 ID
project.namestring项目名称
project.descriptionstring项目描述
project.web_urlstring项目的 Web 访问地址
project.avatar_urlstring项目头像的 URL 地址
project.git_ssh_urlstring项目的 SSH 克隆地址
project.git_http_urlstring项目的 HTTP 克隆地址
project.namespacestring项目的命名空间
project.visibility_levelinteger项目可见性级别(0: 私有, 1:公开)
project.path_with_namespacestring带命名空间的项目路径
project.default_branchstring项目的默认分支
project.homepagestring项目主页 URL
project.urlstring项目 Git 仓库 URL
project.ssh_urlstring项目 SSH 克隆 URL
project.http_urlstring项目 HTTP 克隆 URL
commits[].idstring提交的 SHA 值
commits[].messagestring提交信息
commits[].timestampstring提交时间戳
commits[].urlstring提交详情页面的 URL
commits[].author.namestring提交作者的名称
commits[].author.emailstring提交作者的邮箱
commits[].addedarray本次提交新增的文件列表
commits[].removedarray本次提交删除的文件列表
commits[].modifiedarray本次提交修改的文件列表
total_commits_countinteger本次推送的提交总数
push_optionsarray推送选项数组
repository.namestring仓库名称
repository.urlstring仓库 Git URL
repository.descriptionstring仓库描述
repository.homepagestring仓库主页 URL
repository.git_http_urlstring仓库 HTTP 克隆地址
repository.git_ssh_urlstring仓库 SSH 克隆地址
repository.visibility_levelinteger仓库可见性级别(0: 私有, 1: 公开)
git_branchstring推送的目标分支名称
git_commit_nostring最新提交的 SHA 值
manual_buildboolean
uuidstring本次推送事件的唯一标识符

请求参数示例

{
"object_kind": "push",
"event_name": "push",
"before": "1d27e394fbd0491f139dd2e577aa3e214a2fc18e",
"after": "d55f9d34de9537bddaae80d6dcfe07aaa15e957a",
"ref": "refs/heads/main",
"checkout_sha": "d55f9d34de9537bddaae80d6dcfe07aaa15e957a",
"message": "",
"user_id": 173794,
"user_name": "xiaogang_o",
"user_username": "xiaogang_o",
"user_email": "",
"user_avatar": "https://cdn-img.gitcode.com/ee/ca/756863eec250a6a067148d4d4fe71d28c3b9716a6f79c03a9f460543fa3dc838.jpg?time=1711433667506",
"project_id": 1848674,
"project": {
"id": 1848674,
"name": "test",
"web_url": "https://gitcode.com/xiaogang_o/test",
"avatar_url": "https://cdn-img.gitcode.com/ee/ca/756863eec250a6a067148d4d4fe71d28c3b9716a6f79c03a9f460543fa3dc838.jpg?time=1711433667506",
"git_ssh_url": "git@gitcode.com:xiaogang_o/test.git",
"git_http_url": "https://gitcode.com/xiaogang_o/test.git",
"namespace": "xiaogang_o",
"visibility_level": 0,
"path_with_namespace": "xiaogang_o/test",
"default_branch": "main",
"homepage": "https://gitcode.com/xiaogang_o/test",
"url": "git@gitcode.com:xiaogang_o/test.git",
"ssh_url": "git@gitcode.com:xiaogang_o/test.git",
"http_url": "https://gitcode.com/xiaogang_o/test.git"
},
"commits": [
{
"id": "d55f9d34de9537bddaae80d6dcfe07aaa15e957a",
"message": "update: 更新文件 你好.txtSigned-off-by: xiaogang_o <xiaogang@csdn.net>",
"timestamp": "2025-05-07T05:58:22Z",
"url": "https://gitcode.com/xiaogang_o/test/commits/detail/d55f9d34de9537bddaae80d6dcfe07aaa15e957a",
"author": {
"name": "xiaogang_o",
"email": "xiaogang@csdn.net"
},
"added": [],
"removed": [],
"modified": [
"你好.txt"
]
}
],
"total_commits_count": 1,
"push_options": [],
"repository": {
"name": "test",
"url": "git@gitcode.com:xiaogang_o/test.git",
"homepage": "https://gitcode.com/xiaogang_o/test",
"git_http_url": "https://gitcode.com/xiaogang_o/test.git",
"git_ssh_url": "git@gitcode.com:xiaogang_o/test.git",
"visibility_level": 0
},
"git_branch": "main",
"git_commit_no": "d55f9d34de9537bddaae80d6dcfe07aaa15e957a",
"manual_build": false,
"uuid": "d6869f2d-56a3-4b77-90ee-f4957e582df6"
}