It's all about the answers!

Ask a question

RTC/Git integration: who's done it/how well does it work?


Paul Smith (26122) | asked Oct 17 '11, 5:30 p.m.
Hi all. I've read the "Integrating other SCM Systems with Rational Team Concert 2.0" document from 2009, which gives a lot of detail but is a little lacking as to the higher-level pros and cons, and searched these forums looking for people who've actually implemented this integration but haven't found much.

Has anyone out there actually implemented the RTC/Git bridge described in the above document? How is it working for you? Do you have any advice? Are you willing to give a general overview of how your system works? With a DVCS there are lots of decisions to make (it seems to me); do you connect RTC with only the "master" git repository? All of them? Etc. Is there any existing community around this environment that I can contact?

What features of RTC does one lose by choosing the Git bridge instead of the builtin SCM? The above doc just says "it is possible to provide a similar type of integration between RTC work items and other SCM systems by using comments and the "Related Artifacts" links provided by the Work Items component. The level of integration will not be as high as with RTC SCM but it is useful none the less"; I'm wondering exactly what "not as high" means: what features are preserved, and which are not.

Finally in some of my readings I've seen discussion of a "connector", while the above doc describes a Git "bridge". Are "connector" and "bridge" different names for the same thing? If not what is the advantage of a connector over a bridge (or vice versa), and if a connector gives tighter integration then is there one available for Git and/or would it be difficult to create one?

Thanks for any guidance/pointers/guidelines anyone can provide!
Cheers!

22 answers



permanent link
Amrinder Singh (6111) | answered Aug 13 '14, 2:48 p.m.

Yeah sorry, i didnt see the comment there..I see you created a soft link..so I downloaded the zip for hooks provided by IBM and unzipped them on my local and edited the scripts mentioned in Readme.txt and placed them on server in /hooks folder for my repo. yours is a nice way to link to multiple repos.

Next thing..I'll check my python-3.3.5 installation again..i downloaded a .tgz tarball and untar it but i think all i have is source code and not executable


Comments
Amrinder Singh commented Aug 13 '14, 3:04 p.m.

Also my system has python 2.7. Just because rtc-git integration requires python 3.3.5, do i have to make it as default for everything?


sam detweiler commented Aug 13 '14, 3:14 p.m. | edited Aug 13 '14, 3:40 p.m.

because the git integration provides some pre-compiled (pyc) python files, the interpreter version must match almost exactly.
2.7 will not work, 3.0 will not work, 3.2 will not work. (I tried!)..

you will get invalid magic key errors, indicating mismatch between pre-compiled and interpreter.

I ended up installing ActivePython 3.3.4.1 (download, unzip, run install.sh)



Amrinder Singh commented Aug 19 '14, 5:42 p.m.

Hey Sam.. thanks for the guidance so far but I have a doubt regarding Python.

I have Python 2.7 and 3.3.4 installed and default is set to 2.7. I dont want to change that but how do i make sure that integration python scripts use 3.3.4 an not 2.7?


sam detweiler commented Aug 19 '14, 9:06 p.m.

I have both as well, but only set the explicit path in the post-receive hook file

pythonPath=/opt/ActivePython-3.3/bin/python3.3


permanent link
Amrinder Singh (6111) | answered Aug 13 '14, 3:38 p.m.
So the latest version of ActivePython is is 3.3.4.1, would that work? or its the same thing

Comments
sam detweiler commented Aug 13 '14, 3:41 p.m.

yes, I  corrected my comment, that is the same I installed


permanent link
Amrinder Singh (6111) | answered Aug 13 '14, 4:27 p.m.

Ok so I installed ActivePython-3.3.4.1 by running ./install.sh and its installed in opt/ActivePython-3.3/bin/python, but to run python I see two files python3 and python3.3, which one do i execute or they are same?

"Wish I could put my snap in here"


Comments
sam detweiler commented Aug 13 '14, 4:30 p.m.

I used python3.3 and the script executes now.. fails connecting to RTC cause I haven't finished the config yet., but at least doesn't crash for bad interpreter version.


permanent link
Amrinder Singh (6111) | answered Aug 13 '14, 5:45 p.m.

So couple of things I did today to fix my python mess:

1) Installed ActivePython-3.3.4.1 (default install location: /opt/ActivePython-3.3/bin)

2) Edited my Python scripts( post-receive, pre-receive, ref-update and ref-updated.py) by adding a shebang at the beginning of my script (#!/opt/ActivePython-3.3/bin/python3.3) though python 2.7 is installed but I think this shebang will help execute what version of Python I want.

So one of IBM requirement is to mention HOOKS_PATH in the scripts Example: Location where Git Python hook scripts are copied

example hooksPath="C:/PythonScripts/rtcgithooks"

So to do this we need to create a rtcgithooks folder and copy all hook scripts there?


Comments
sam detweiler commented Aug 13 '14, 7:00 p.m.

my post-receive hook script from ibm says

$pythonPath $hooksPath/AssociateWorkitem.py .....

my expanded script would say

/opt/ActivePython-3.3/bin/python3.3 /opt/rtc-git/AssociateWorkitem.py ...

so the two paths are not needed to be together..


sam detweiler commented Aug 13 '14, 11:34 p.m.

I finally got my web git  interface working git-web on tomcat.  and was able to registr the repo. this generates a  key that is needed in the hook script.  so the link approach won't work.  as each repo has a different key..

anyhow. bug workitem_number in the commit comment then puts a link to the git change set in the workitem





permanent link
Amrinder Singh (6111) | answered Aug 14 '14, 11:08 a.m.

So in my pre-receive script I have this after all editing:

#!/opt/ActivePython-3.3/bin/python3.3

remote="$1"
url="$2"
userId="$REMOTE_USER"
z40=0000000000000000000000000000000000000000
IFS=' '
jazzRepoUrl=https://ptcpassbuild1:9443/jazz/
gitRepoKey=a2c8741789234b599a145aa2827c7e04
pythonPath=/opt/ActivePython-3.3/bin/python3.3
hooksPath=/opt/ActivePython-3.3/share/python3.3/scripts/rtcgithooks

while read oldRev newRev refName; do
  echo oldRev=$oldRev newRev=$newRev refName=$refName
  echo "GIT/RTC Sucks together"
  $pythonPath $hooksPath/ValidatePush.py $jazzRepoUrl $gitRepoKey $userId $oldRev $newRev $refName
  if [ $? -ne 0 ];
  then
    exit 1
  fi
done

exit 0

and I try to execute this script manually it throws syntax error:invalid Syntax on below url..

Dont know why??but will try troubleshooting

jazzRepoUrl=https://ptcpassbuild1:9443/jazz/


permanent link
Amrinder Singh (6111) | answered Aug 14 '14, 11:12 a.m.
But overall I have registered Git repository but still the integration doesnt work....

Comments
sam detweiler commented Aug 14 '14, 11:24 a.m.

and in the git commit message you have to put some specific text to trigger the integration

bug rtc_workitem_number message

like

bug 7 test with rtc

you should see this on workitem 7

and click on that link will show in a browser




permanent link
Amrinder Singh (6111) | answered Aug 14 '14, 11:32 a.m.

My GIT commit is like this:

git commit -s -m "fix defect 419901" and then I push it and then I got to links in RTC but nothing comes up.

Is this message correct?


Comments
sam detweiler commented Aug 14 '14, 12:20 p.m. | edited Aug 14 '14, 12:22 p.m.

according to http://www-01.ibm.com/support/knowledgecenter/api/content/SSYMRC_5.0.0/com.ibm.team.connector.cq.doc/topics/t_git_assoc_wi.html

yes..

just to make sure.. the post-receive hook script is either in
/git/repo/hooks
or
linked to from there..

it MUST be in the git repo hooks folder for GIT to call it.
the IBM provided hook code calls out to other services in the $hooksPath folder.
but git knows nothing about that


permanent link
Amrinder Singh (6111) | answered Aug 14 '14, 12:34 p.m.

I have my scripts in below loactions:

1) For Git repo: /media/storage/gerrit2/review_site/git/testproject2.git/hooks

{hookslib.pyc, post-receive.py, pre-receive.py, rtcprocess.pyc and commit-msg}

2) For Gerrit : /media/storage/gerrit2/review_site/hooks

{ref-update.py and ref-updated.py}

3) For hooks path: /opt/ActivePython-3.3/share/python3.3/scripts/rtcgithooks

{AssociateWorkItem.py, hookslib.pyc, post-receive.py, pre-receive.py, ref-update.py, ref-updated.py, rtcprocess.pyc and ValidatePush.py}

For this integration I have modified post-receive, pre-receive , ref-update and ref-updated scripts.

Please let me know if any script needs to be placed in any other folder/directory?


permanent link
sam detweiler (12.5k6195201) | answered Aug 14 '14, 1:06 p.m.
1) For Git repo: /media/storage/gerrit2/review_site/git/testproject2.git/hooks {hookslib.pyc, post-receive.py,
pre-receive.py, rtcprocess.pyc and commit-msg}

only post-receive needs to be in the hooks folder. 

post-receive is the thing git calls. and ONLY that file on push.  it must be executable too
chmod +x post-receive

the others are in the location where the ibm files are
/opt/ActivePython-3.3/share/python3.3/scripts/rtcgithooks

permanent link
Amrinder Singh (6111) | answered Aug 14 '14, 4:13 p.m.

Yeah I'll do that.. Its weird I only changed the Url and path in scripts and now I tried running post-receive.py scripts manually and I get a syntax error:

file "./post-receive.py", line 35

  while read local_ref local_sha remote_ref remote_sha; do

SyntaxError: invalid syntax.

Did you try running urs?


Comments
sam detweiler commented Aug 14 '14, 4:27 p.m.

I don't have a post-receive.py

only a post-receive, and pre-receive
the py files I have are AssociateWorkitem.py and ValidatePush.py
and two pyc files.

also two gerrit windows batch files.

the filename put into the git repo hooks folder should be 'post-receive'
no extension...  its a linux shell script.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.