将代码从Bitbucket部署到EC2

时间:2015-08-01 17:59:16

标签: php git amazon-web-services amazon-ec2 bitbucket

我正在为我的Django项目使用BitBucket,为云服务器使用EC2。我的目标是当我将提交推送到分支时,BitBucket将在钩子上进行调用,钩子将更新EC2中的代码。

到目前为止,当我提交时,会调用钩子,但代码不会在服务器上更新。根据我的理解,这与Linux / Ubuntu 14.04中的权限有关。

我尝试按照Brandon Summers中的链接进行操作,并通过here进一步完善相同的内容。但它仍然无效。

使用第一个链接,我在日志中得到了这个:

fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
chmod: cannot access '.git': No such file or directory
[Thu Jul 30 18:21:05.106127 2015] [:error] [pid 9736] [client 131.103.20.165:42727] PHP Notice:  Undefined property: Deploy::$_data in /var/www/html/deploy_home.php on line 127

第二个链接在控制台中给我这个:

[Sat Aug 01 15:26:35.000824 2015] [:error] [pid 2447] [client 131.103.20.165:39102] PHP Warning:  file_put_contents(/var/log/deploy/deployments.log): failed to open stream: No such file or directory in /var/www/html/deploy_repo.php on line 144
[Sat Aug 01 15:26:35.000869 2015] [:error] [pid 2447] [client 131.103.20.165:39102] PHP Warning:  chmod(): No such file or directory in /var/www/html/deploy_repo.php on line 147
[Sat Aug 01 15:26:35.000924 2015] [:error] [pid 2447] [client 131.103.20.165:39102] PHP Warning:  file_put_contents(/var/log/deploy/deployments.log): failed to open stream: No such file or directory in /var/www/html/deploy_repo.php on line 152
[Sat Aug 01 15:26:35.001010 2015] [:error] [pid 2447] [client 131.103.20.165:39102] PHP Warning:  file_put_contents(/var/log/deploy/deployments.log): failed to open stream: No such file or directory in /var/www/html/deploy_repo.php on line 144
[Sat Aug 01 15:26:35.001034 2015] [:error] [pid 2447] [client 131.103.20.165:39102] PHP Warning:  chmod(): No such file or directory in /var/www/html/deploy_repo.php on line 147
[Sat Aug 01 15:26:35.001068 2015] [:error] [pid 2447] [client 131.103.20.165:39102] PHP Warning:  file_put_contents(/var/log/deploy/deployments.log): failed to open stream: No such file or directory in /var/www/html/deploy_repo.php on line 152
sh: 1: /usr/sbin/sendmail: not found

第二个链接的控制台输出与无法写入日志文件有关,但EC2上的repo文件夹仍保持不变。

我在这里缺少什么?

1 个答案:

答案 0 :(得分:1)

首先,我猜您错过了deploy中的var/log目录。尝试手动创建它。这样至少你会有一些日志文件需要分析。

其次,你还没有在这里展示你的脚本,但值得一提的是这个脚本使用的是旧的Bitbucket IP;如果您还没有改变它,请尝试替换此行中的IP,

 private $_repositoryIp = array ( '63.246.22.222');

使用您可以找到的新IP地址之一here

第三,为什么在Jenkins等CI工具可以做所有努力?一些有用的帖子:12