I have a rails server running in my Ubuntu 14.04 instance and I host my code in github.com. For user's pushing to github, I have setup a webhook to my app which listens to any POST call from github and tries to execute a ruby script gitscript.rb when the POST has all correct payloads.
Unfortunaltely the script doesn't do a git pull and I am stumped to run this perfectly. Any help would be appreciated.
Below is my code to listen to webhooks and it runs the script, but the commands in the script don't run, I have all the permission required for the ruby script.
def webhooks
push = JSON.parse(request.body.read)
if some_condition_that_should_be_true
logger.info "Yes go ahead and pull"
logger.info "Ran the git pull command" if `cd /home/server && git pull >> cat.txt`
logger.info "Ran the ruby" if `ruby /home/server/gitscript.rb`
logger.info "Last command"
else
logger.info push
end
render :json => { :code => 'Webhooks came good' }, :status => 200
end
And my ruby script is below and yes it has all permissions correct, for test sake I made them 777
!/bin/env ruby
cd /home/server && git pull
The user running your script probably does not have read/write rights on the git repository (not talking about permissions here, but more about deploy-keys
which are just SSH keys allowing a user to read and/or write from/to a remote git repo).
Can you git pull
as the user which is running this script on your server ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.