我正在同一台服务器上运行GitLab v5.2和我的生产Web服务器(文档根目录在/var/www)。
我正在尝试设置标准的GitLab Post-Receive Hook,但是发现关于如何设置处理发布JSON数据的脚本的信息非常少。我不想做任何自定义,只是想要在我的网站位置(记住是在同一台服务器上)接收post-receive数据,然后在接收到数据时从origin-master进行pull(前提是post-receive数据起始推送是到主分支)。这样,在/var/www中找到的网站始终与主分支相同。
有人可以给我一个从post数据中拉出脚本的例子,或者指点我创建一个的正确方向吗?
GitLab Hook请求示例 - 对于那些没有GitLab实例的人,这是GitLab Post-Receive 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,
};