2

Is there any way to automatically release the current master and/or branches to /var/www/html/repositoryname with gitolite?

I've tried setting symbolic links but realised that gitolite repositories keep files packaged except for the .git directory.

Creating post hooks was one suggested solution for this kind of problem but I was not able to find a suitable application for my case.

Theo
  • 2,262
  • 3
  • 23
  • 49

1 Answers1

1

Creating post hooks was one suggested solution for this kind of problem but I was not able to find a suitable application for my case.

Yes, a post-receive hook is the recommended solution.
See for instance "GIT post-receive checkout without root folder"

Except that, with gitolite, you now have a repo specific hook.
See "repo-specific hooks"

add this line in the rc file, within the %RC block, if it's not already present, or uncomment it if it's already present and commented out:

LOCAL_CODE => "$rc{GL_ADMIN_BASE}/local",

uncomment the 'repo-specific-hooks' line in the rc file or add it to the ENABLE list if it doesn't exist.

If your rc file does not have an ENABLE list, you need to add this to the POST_COMPILE and the POST_CREATE lists.
Click here for more on all this.

put your hooks into your gitolite-admin clone, as follows:

# on your workstation
cd /path/to/your/gitolite-admin-clone
mkdir -p local/hooks/repo-specific

Now add your hooks to that directory, but instead of using the git "standard" names (pre-receive, post-receive, post-update), you use descriptive names (e.g. "deploy", "RSS-post", etc).

add them to the repos you want them to be active in, in your conf file. For example:

repo foo
    option hook.post-update     =   jenkins
repo bar @baz
    option hook.post-update     =   deploy RSS-post

add, commit, and push the admin repo.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • that is very helpful! Where do I define the path to the /var/www/html/reponame though? – Theo Jul 12 '17 at 10:48
  • @Thodi In your hook script, as shown in https://stackoverflow.com/a/15930178/6309 `git --git-dir=/path/to/project_root/.git --work-tree=/path/to/website/httpdocs checkout -f`: replace the second path by the one you mention, and the first one by the bare repo path managed by gitolite. – VonC Jul 12 '17 at 12:10