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 14 '14, 5:23 p.m.

The reason why I had .py extension is I thought we are installing python 3.3.4 and the scripts will use it apart from .py scripts provided by IBM (AssociateWorkitem.py and validatepush.py)

So for post-receive, did you change the extension to .sh then? Do you mind sharing your post-receive script if possbile?


Comments
sam detweiler commented Aug 14 '14, 5:31 p.m. | edited Aug 14 '14, 5:31 p.m.

git expects the two hooks, pre-receive and post-receive to be named exactly that. no extensions

those scripts USE python to run the NEXT STEPS..  but their names MUST BE as expected or git cannot call them

all I changed in post-receive is this

userId="sam"
jazzRepoUrl='https://detweiler.dyndns.org:9445/ccm'
gitRepoKey=ef499d2b98da465ea1beebc30778495a
pythonPath="/opt/ActivePython-3.3/bin/python3.3"
hooksPath="/opt/rtc-git"


permanent link
Amrinder Singh (6111) | answered Aug 14 '14, 4:43 p.m.
but then the batch files for gerrit.. i have to change their extension right? because they are in linux

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

you will have to rewrite/convert them to linux shell scripts. IBM only provided windows batch files.

they are not long and are easy to convert if you know linux scripting.
most of it is very similar to the provided post-receive script.

I don't know anything about gerrit.


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.


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, 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
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, 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: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 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 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.

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.