2

I am trying to setup github to websever deployment automation. I've got everything working except the most important bit. I have a file @ mydomain.com/github.php that looks like this:

<?php
`git pull`;
?>

and this is the post-receive URL for my github repo. Github is posting to it successfuly, but the shell command is not running. When I try SSHing into my server, and running the script directly:

php github.php

it works just fine and changed files are pulled succesfully

From git://github.com/user/Repo
   7e3176d..f889c14  master     -> origin/master

but when accessing the page in my browser or when github POSTs to it - the shell command is not executed. There is no error - just an empty result. What am I doing wrong here?

11
  • 1
    I've never seen that PHP syntax before Commented Feb 19, 2012 at 20:05
  • 2
    php.net/manual/en/language.operators.execution.php I just learned about it the other day myself :) Commented Feb 19, 2012 at 20:06
  • try <?php echo git pull ?> Commented Feb 19, 2012 at 20:07
  • @KubaW did you mean to put git pull inside backticks? Commented Feb 19, 2012 at 20:10
  • @Yev: yep, it will output the execution results Commented Feb 19, 2012 at 20:11

1 Answer 1

3

There are 2 possible issues:

  1. Permissions - most likely your webserver user doesn't have necessary
  2. Work directory. Double check that your shell command is being executed in correct path (getcwd())

UPD

Git outputs the error messages to stderr, so to see the real error message you need

echo `git pull 2>&1`;
Sign up to request clarification or add additional context in comments.

2 Comments

1. I am doing this on one of the subaccounts of my VPS. I have full control to go in and make the nessecary changes to permissions, but unfortuantely I'm not sure how/where I would do this. Could you give me some guidance how I would be able to check and set the appropriate permissions? 2. The current working directory is correct.
"error: cannot open .git/FETCH_HEAD: Permission denied" is the error I am receiving.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.