3

I'm trying to enforce some policies between a Git and Rational Team Concert using server side hooks. i.e. pre-receive one, but that hook seems not to be fired. Even susbsituting given rational hook with a simple bash shell that rename a file this doesn't appear to be executed. I put the script under /hooks dir with 755 permission, it works fine if executed from the shell. How can I check where problem is? Which log can I look at ?

This is the simple shell I'm trying to execute as pre-receive hook

#!/bin/bash
#
# Licensed Materials - Property of IBM
# (c) Copyright IBM Corporation 2014. All Rights Reserved.
# 
#  Note to U.S. Government Users Restricted Rights:  
#  Use, duplication or disclosure restricted by GSA ADP Schedule 
#  Contract with IBM Corp. 
#
#

z40=0000000000000000000000000000000000000000
IFS=' '

date >> /tmp/test.txt
#mv /tmp/ss/daeseguire.txt /tmp/ss/eseguito.txt
exit 1

Thanks in advance

simsabat
  • 31
  • 3
  • Hi, welcome to SO! Please provide a [mcve], so that we could help you better! – hatef Feb 22 '17 at 16:43
  • Thank you for your suggestion, I'm a newbie here. I've modified the original question: – simsabat Feb 22 '17 at 17:30
  • simsabat: Did you solve the issue? I have the more or less similar problem. I can not check the hook is run or not – GergA Sep 05 '17 at 14:42

2 Answers2

1

Don't forget that a pre-receive hook is a server-side hook.

That means, if you have a local git repo nested within your RTC sandbox (which is the local checkout of an RTC repo workspace), that local Git repo will not execute a .git/hooks/pre-receive script.

If you have setup the RTC-Git integration, then the official documentation is "Configuring Git and Gerrit server-side hooks".
But it supposes the configuration step is done and working, which means you can look at the Apache log to see if there is any clues.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you for your answer. First of all I'm using git with a remote repository, on a Linux RHEL with Apache, repository is under /var/www/html – simsabat Feb 23 '17 at 09:32
  • then, I'm not still firing RTC given hooks, since I cannot even fire a simple shell hook. – simsabat Feb 23 '17 at 09:38
  • @simsabat are you using the official RTC-Git integration? – VonC Feb 23 '17 at 09:40
  • I would like to, but how can I use a complex hook like the RTC one if I'm not able to let the system execute a single one? – simsabat Feb 23 '17 at 13:49
  • @simsabat I agree: let's debug that first: when you do a git push, are you pushing to that specific remote Git repo through your Apache you mentioned before? – VonC Feb 23 '17 at 13:57
  • I'm pushing from my local copy of git repo towards remote git repo that is located under folder: /var/www/html – simsabat Feb 23 '17 at 14:56
0

this is the output of my push operation:

$ git push --verbose Getting pack list Fetching remote heads...
refs/ refs/tags/ refs/heads/ updating 'refs/heads/master' from decabae30c2b8cfac8e2795a1da342ce9e22ec12 to
6e583f66c4410fd0e2ee18ee491236f16d05f64b sending 5 objects sent 707de30e348030620f1e49d14f4e7cf108e305c9 sent 4d9de1b3a723b21d6855354dd6867c72e4853b43 sent 6e583f66c4410fd0e2ee18ee491236f16d05f64b sent a9e64e39116bc7abd9af2c5eeaa071e4a4243294 sent 845de842759b28a53651c86073afa9ce6e30577e done Updating remote server info Pushing to http://172.24.113.41/pico2.git/ To http://172.24.113.41/pico2.git/
decabae..6e583f6 master -> master updating local tracking ref 'refs/remotes/origin/master'

simsabat
  • 31
  • 3