4

I need to set up post-receive hook script on Gitblit server that will pull changes to a website on the same server. In a bash script, command would look something like this:

sudo git --work-tree=/var/www/html/mysite --git-dir=/var/www/html/mysite/.git pull

But as I understand, Gitblit uses groovy hooks scripts, and I'm completely new to this. Can someone please help me with creating a groovy script for this, or at least direct me to some good examples or tutorial for Groovy.

Thanks

cakan
  • 2,099
  • 5
  • 32
  • 42
  • 1
    do you just need this command "in groovy" or do you lack the general understanding how such a thing is done with gitblit?. the groovy code is `["sudo", "git", "--work-tree...", ...].execute()` – cfrick Nov 07 '14 at 08:15
  • Both. I just heard of Groovy yesterday, and all examples I saw seem too complex. Basically, I need a groovy script that will do that command. – cakan Nov 07 '14 at 08:16

1 Answers1

4

In case someone needs help with groovy, here is my groovy script:

import org.slf4j.Logger

def res = ["git", "--work-tree=/var/www/html/mysite", "--git-dir=/var/www/html/mysite/.git", "pull"].execute()

println res.err.text
println res.text
cakan
  • 2,099
  • 5
  • 32
  • 42