位桶网络钩子
Bitbucket Webhooks
我想将我的一个项目自动部署到我的服务器上。
我通过 bitbucket 使用 git 来对我的软件进行版本控制。
我遇到了这个 this 不错的教程。不幸的是我无法让它工作。
如果我从我的本地工作副本推送更改,远程仓库会更新,但 webhook 会给我 404
错误。因此与我的服务器建立了通信,但未找到脚本。
当我通过 php bitbucket-hook.php
手动启动脚本时,在 repo 上发出了拉取请求,一切都按预期进行。
我猜 URL 有问题。我试了 http://ip.ip.ip.ip/home/<username>/app/deploy/bitbucket-hook.php
还有域名。
我自己实现了很多次 webhook。
您用来访问 .php 文件的路径不正确。此路径应相对于您的 apache DocumentRoot(例如 /var/www/html)
假设您的 DocumentRoot 是 /var/www/html 然后将您的 bitbucket-hook.php 文件放入此路径(即 /var/www/html/bitbucket-hook.php)并使用 URL 作为 http://ip.ip.ip.ip/bitbucket-hook.php
或者,您可以创建一个指向 /(root)的虚拟主机并使用 http://ip.ip.ip.ip/home/{username}/app/deploy/bitbucket-hook.php
注意:您还需要在 /var/www 中添加带有私钥的 .ssh 文件夹,因为当您触发 webhook 时,apache 将在其主文件夹中找到密钥,即 /var/www.
这是我写给 autodeploy
的 bash 的一部分
`
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
`
希望对您有所帮助:)
我想将我的一个项目自动部署到我的服务器上。 我通过 bitbucket 使用 git 来对我的软件进行版本控制。 我遇到了这个 this 不错的教程。不幸的是我无法让它工作。
如果我从我的本地工作副本推送更改,远程仓库会更新,但 webhook 会给我 404
错误。因此与我的服务器建立了通信,但未找到脚本。
当我通过 php bitbucket-hook.php
手动启动脚本时,在 repo 上发出了拉取请求,一切都按预期进行。
我猜 URL 有问题。我试了 http://ip.ip.ip.ip/home/<username>/app/deploy/bitbucket-hook.php
还有域名。
我自己实现了很多次 webhook。
您用来访问 .php 文件的路径不正确。此路径应相对于您的 apache DocumentRoot(例如 /var/www/html)
假设您的 DocumentRoot 是 /var/www/html 然后将您的 bitbucket-hook.php 文件放入此路径(即 /var/www/html/bitbucket-hook.php)并使用 URL 作为 http://ip.ip.ip.ip/bitbucket-hook.php
或者,您可以创建一个指向 /(root)的虚拟主机并使用 http://ip.ip.ip.ip/home/{username}/app/deploy/bitbucket-hook.php
注意:您还需要在 /var/www 中添加带有私钥的 .ssh 文件夹,因为当您触发 webhook 时,apache 将在其主文件夹中找到密钥,即 /var/www.
这是我写给 autodeploy
的 bash 的一部分`
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
`
希望对您有所帮助:)