Bitbucket Accounts

I want to automate the deployment of one of my projects on my server. I use git via a bitbucket to control my software version. I went through this this good tutorial. Unfortunately, I cannot get it to work.

If I push the changes from my local working copy, the remote repo is updated, but the webhook gives me a 404 error. Thus, a connection with my server was established, but the script was not found.

When I manually run the script through php bitbucket-hook.php , the php bitbucket-hook.php request is issued to the repo and everything works as expected.

I think something is wrong with the url. I tried http://ip.ip.ip.ip/home/<username>/app/deploy/bitbucket-hook.php as well as the domain name.

+2
source share
1 answer

I myself used webhook quite often.

The path you use to access the .php file is incorrect. This path should apply to your DocumentRoot apache (e.g. / var / www / html)

say your DocumentRoot is / var / www / html, and then put the bitbucket-hook.php file in this path (e.g. / 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 that points to / (root) and use http: //ip.ip.ip.ip/home/ {username} /application/deployment/BitBucket-hook.php

NOTE. You also need to add your .ssh folder with the private key to / var / www, since when you start the web cache then apache will find the key in its home folder ie / var / www.

Here is the part of my bash that I wrote for 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 

`

Hope this helps :)

+3
source

Source: https://habr.com/ru/post/989589/


All Articles