Bitbucket Webhooks

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

I want to automate the deployment of one of my projects onto my server. I m using git via bitbucket to version control my software. I came accross this this nice tutorial. Unfortunately i cannot get it to work.

If i push changes from my local working copy, the remote repo gets updated but the webhook gives me the 404 error. So communication with my server was established but the script was not found.

When i manually start the script via php bitbucket-hook.php a pull request is issued on the repo and everything works as expected.

I guess something is wrong with the URL. I tried http://ip.ip.ip.ip/home/<username>/app/deploy/bitbucket-hook.php and also the domain name.

回答1:

I have implemented the webhook myself quite a times.

The path you are using to access the .php file is incorrect. This path should be relative to your DocumentRoot of apache (eg /var/www/html)

say your DocumentRoot is /var/www/html then put your bitbucket-hook.php file in in this path (i.e. /var/www/html/bitbucket-hook.php) and use the URL as http://ip.ip.ip.ip/bitbucket-hook.php

Alternatively, you can make a Virtual host which points to / (root) and use http://ip.ip.ip.ip/home/{username}/app/deploy/bitbucket-hook.php

NOTE : you also need to add your .ssh folder with private key in /var/www as when you trigger the webhook then apache will find the key in its home folder i.e. /var/www.

Here is part of my bash which I have written to autodeploy

`

echo "implenting the web hook for auto deployment..." if ! [[ -d /var/www/.ssh ]]; then sudo cp -R ~/.ssh /var/www/ if [[ \$? == 0 ]];then echo -e 'copied ~/.ssh to document root to apache [/var/www]\n' else echo -e 'something went wrong while copying ~/.ssh to /var/www\n' fi else echo "Already a folder name .ssh in /var/www" fi sudo chown -R apache. /var/www/.ssh 2>&1 if [[ \$? == 0 ]];then echo -e 'ownership of /var/www/.ssh has changed to apache \n' else echo -e 'something went wrong while changing ownership of /var/www/.ssh\n' fi pushd /var/www/html touch auto_pull.php sudo chown apache. auto_pull.php echo -e "<?php content to write in php file ?>">>auto_pull.php   popd 

`

I hope this will help :)



文章来源: Bitbucket Webhooks
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!