git@OSC上,使用PUSH钩子,每次push就通过URL访问项目下面的自动部署php文件<?header("Content-type: text/html; charset=utf-8");$js=json_decode($_REQUEST["hook"]);//json转换if($js->password!="xxxxxx")die("ERROR!");//判断密码$fp=fopen("./log.txt",'a');$lastcommit=$js->push_data->commits[count($js->push_data->commits)-1];//获取最后的commitif(strstr($lastcommit->message,"release"))//这里意为:如果最后的commit包含"release"则进行自动发布。{exec('cd /home/xxx/');//进入目录exec("git pull origin master");//进行git拉取,前提是使用了sshfwrite($fp,"!!!".date('Y-m-d H:i:s')."\t".$lastcommit->message."\t".$lastcommit->author->name."\t"."Y"."\n");//进行记录}else{fwrite($fp,date('Y-m-d H:i:s')."\t".$lastcommit->message."\t".$lastcommit->author->name."\t"."N"."\n");}每次push后,项目下面的log.text确实有记录,但是代码没更新,还是得每次都手动git pull一下。这该如何是好啊?
- 2 回答
- 0 关注
- 2103 浏览
添加回答
举报
0/150
提交
取消