当我推送到Bitbucket时,一个钩子可以让VPS'拉'出来 [英] A hook that let `pull` from VPS when I `push` to Bitbucket

查看:330
本文介绍了当我推送到Bitbucket时,一个钩子可以让VPS'拉'出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



每次我 push 这个主题,我都必须登录我的VPS服务器并回购。
我想自动执行。



如果我运行git deamon myown,我找到了一个解决方案。
推送到服务器后执行自动拉取请求

但我想使用Bitbucket,因为它也可以作为备份。



我发现关于bitbucket的钩子的文档,但我无法找到如何去做。
https://confluence.atlassian.com/display/BITBUCKET/管理+ Bitbucket +钩子



任何人都可以给我看一个解决方案吗?

/ div>

我对此做了一个非常基本的教程: de / 2013/04 / post-hook-for-git-bitbucketorg.htmlrel =nofollow noreferrer> http://jan1337z.blogspot.de/2013/04/post-hook-for-git-bitbucketorg.html


这个基本步骤是:

$ ol

  • 使用公钥对创建对存储库的只读访问。

  • 将公钥作为部署密钥添加到您的存储库
    (Repository - >设置 - >部署密钥)

  • 将存储库通过SSH提取到WebServer

  • 将git文件夹的所有权更改为www-数据(因为
    是apache2用户)

  • 创建一个执行git pull的公共可访问php脚本

  • 在您的服务器上放置一个POST钩子到您的php-pull脚本(存储库
    - > admin - > Hooks - > POST)

  • 无法找到管理员?

    (在bitbucket上)它的齿轮在右上角。点击它或键入'r',然后'a'。

    基本的PHP脚本来拉取:


     <?php 
    $ output = shell_exec('git pull');
    echo< pre> $ output< / pre>;
    ?>


    我这样做只是为了证明它是可能的。改进它:)

    如何创建部署密钥(步骤2):


    I'm managing my wordpress template in Bitbucket.

    Each time I push the theme, I must log in my VPS server and pull the repo. I want to do it automatically.

    I found a solution if I run git deamon myown. Do an automatic pull request after pushing to server

    But I want to use Bitbucket because it works as a backup also.

    I found a Document about bitbucket's hook, but I could't find how to do it. https://confluence.atlassian.com/display/BITBUCKET/Manage+Bitbucket+hooks

    Could anyone show me a solution?

    解决方案

    I did a very basic tutorial on this:

    this basic steps are:

    1. Create a Read-Only access to the Repository with a public-key pair.
    2. Add the public key as a deployment key to your repository (Repository -> Settings -> Deployment keys)
    3. Pull your Repository to your WebServer via SSH
    4. Change ownership of the git-folder (you pulled) to www-data (as this is the apache2 user)
    5. Create a public accessable php script that executed a git pull
    6. Place a POST-hook to your php-pull-script on your Server (Repository -> admin -> Hooks -> POST)

    Cant find admin?
    while you are on your repository (on bitbucket) its the gearwheel in the top right. Either click on it or type 'r' and then 'a'.

    Basic PHP script to make the pull:

    <?php
        $output = shell_exec('git pull');
        echo "<pre>$output</pre>";
    ?>
    

    I had this running just to proof that it is possible. Improve it :)

    How to create a deployment key (step 2):

    这篇关于当我推送到Bitbucket时,一个钩子可以让VPS'拉'出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆