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 關注
- 2189 瀏覽
添加回答
舉報
0/150
提交
取消