Answer the question
In order to leave comments, you need to log in
How to git pull origin master from php?
There is a repository on bitbucket, when a push is made there, a hook is triggered and a request is sent to the combat server that launches the deploy script. This script should pull from the repository. But for some reason he does not do it, he does not display any errors. The repository is accessed via ssh, all the necessary keys are there, you don’t need to do ssh-add, since everything is set to automatically add there, etc. The rights to the folder are, the owner is the same as running php. In short, everything is fine, and before get pull, I do git reset --hard HEAD and everything works fine. Here is the script itself:
<?php
/**
*
*/
class Deploy implements DeployInterface
{
private $payload;
function __construct()
{
$this->payload = json_decode(file_get_contents('php://input'));
}
public function pull()
{
$output = '';
if ($this->payload) {
chdir('/var/www/'.$this->payload->repository->name);
exec('git reset --hard HEAD', $output);
file_put_contents('test.txt', $output, FILE_APPEND);
exec('git pull origin master', $output);
file_put_contents('test.txt', $output, FILE_APPEND);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question