教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 服务器对接码云webhooks实现自动部署

服务器对接码云webhooks实现自动部署

发布时间:2020-12-31   编辑:jiaochengji.com
教程集为您提供服务器对接码云webhooks实现自动部署等资源,欢迎您收藏本站,我们将为您提供最新的服务器对接码云webhooks实现自动部署资源
本篇文章主要内容讲的是让服务器对接码云webhooks实现自动部署,具有一定参考价值,感兴趣的朋友可以了解一下。

码云 WebHook 功能是帮助用户 push 代码后,自动回调一个您设定的 http 地址。

服务安装git

php代码(外网必须可以访问)


<?php //本地路径滚adminasdfdasfasdf $file = "/wwwroot/webhooksLog.txt"; $_File = fopen($file, "a "); $local = '/wwwroot/test'; //仓库地址 $remote = '远程仓库地址';   //密码 $password = '123456';   //获取请求参数 $request = file_get_contents('php://input'); if (empty($request)) {   die('请求参数为空'); }   //验证密码是否正确 $data = json_decode($request, true); if ($data['password'] != $password) {   die('密码错误'); } fwrite($_File, "************************************************\r\n"); fwrite($_File, "推送人Name: "); fwrite($_File, $data["pusher"]["name"] . "\r\n"); fwrite($_File, "推送人Email: "); fwrite($_File, $data["pusher"]["email"] . "\r\n"); fwrite($_File, "推送人UserName: "); fwrite($_File, $data["pusher"]["username"] . "\r\n"); fwrite($_File, "推送人备注: "); fwrite($_File, $data["head_commit"]["message"] . "\r\n"); fwrite($_File, "推送项目: "); fwrite($_File, $data["repository"]["full_name"] . "\r\n"); fwrite($_File, "推送分支: "); fwrite($_File, $data["ref"] . "\r\n"); fwrite($_File, "推送日期: "); fwrite($_File, $data["head_commit"]["timestamp"] . "\r\n"); fwrite($_File, "************************************************\r\n"); fclose($_File); //return; //echo shell_exec("cd {$local} && git pull {$remote} 2>&1"); system('cd '.$local.' && "C:/Program Files/Git/cmd/git.exe" pull '.$remote.' 2>&1', $out); echo $out; die('done' . date('Y-m-d H:i:s')); ?>

填入域名,点击提交

完成

相关教程:PHP视频教程

以上就是服务器对接码云webhooks实现自动部署的详细内容,更多请关注教程集其它相关文章!

  • 本文转载于:博客园,如有侵犯,请联系jquerycn@qq.com删除
  • 您可能感兴趣的文章:
    服务器对接码云webhooks实现自动部署
    Docker LNMP Jenkins 码云实现 PHP 代码自动化部署
    云原生环境下微服务管理系统开发
    golang微服务框架对比_Golang 微服务教程(二)
    快速部署 Spring PetClinic 到函数计算平台
    支持多语言的微服务框架Tars-Go
    golang微服务框架对比_最强开源微服务框架,全网独家整理
    php分布式怎么部署
    Revel框架应用部署的经验
    超详细分析php docker的原理及作用

    [关闭]
    ~ ~