【发布时间】:2013-06-16 02:59:59
【问题描述】:
我在与我的生产网络服务器相同的服务器上运行 GitLab v5.2(/var/www 中的文档根目录)。
我正在尝试设置一个标准的 GitLab Post-Receive Hook,但我发现关于如何设置脚本来处理发布的 JSON 数据的信息非常少。我不想做任何自定义,开箱即用,我想在我的网站位置接收接收后数据(记住在同一台服务器上),然后在收到时从 origin-master 中提取(前提是发起推送的接收后数据发送到主分支)。这样,在 /var/www 中找到的网站始终是同一主站。
谁能给我一个从帖子数据中提取脚本的示例,或者指出我创建一个正确的方向?
GitLab 挂钩请求示例 - 对于那些没有 GitLab 实例的用户,以下是 GitLab 接收后 JSON 数据的样子(直接来自 GitLab 帮助)
{
"before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
"after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"ref": "refs/heads/master",
"user_id": 4,
"user_name": "John Smith",
"repository": {
"name": "Diaspora",
"url": "git@localhost:diaspora.git",
"description": "",
"homepage": "http://localhost/diaspora",
},
"commits": [
{
"id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"message": "Update Catalan translation to e38cb41.",
"timestamp": "2011-12-12T14:27:31+02:00",
"url": "http://localhost/diaspora/commits/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"author": {
"name": "Jordi Mallach",
"email": "jordi@softcatala.org",
}
},
// ...
{
"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"message": "fixed readme",
"timestamp": "2012-01-03T23:36:29+02:00",
"url": "http://localhost/diaspora/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"author": {
"name": "GitLab dev user",
"email": "gitlabdev@dv6700.(none)",
},
},
],
"total_commits_count": 4,
};
【问题讨论】:
标签: json git gitlab webhooks git-post-receive