Git post-checkout hooks
We have TeamCity version 2017.1.3 with ARM plugin. Server's (and agent's) OS is Windows server 2016. Our project (A) contains references to another project (B) which is pulled after checkout on project A with using post-checkout hook.
But post-checkout hook is not working for us when job starts and checkouts directory. However when I try to checkout from build step using command "git checkout HEAD", hook is working.
Is there any way to turn on hooks for TC checkouts? I didn't find any plugin or workaround to solve this.
Please sign in to leave a comment.
How do you have the post-checkout hooks set up?
in repository we have file .git -> hooks -> post-checkout. This file is created on machine with running .bat file. It is set on agent. Hook should call RestoreB.bat which checkout B in desired version.
Adding hook:
echo Adding post-checkout hook...
echo.>> %POST_CHECKOUT_HOOK_PATH%
echo # Generated by B initialization script>> %POST_CHECKOUT_HOOK_PATH%
echo ./%CHECKOUT_B_SCRIPT%>> %POST_CHECKOUT_HOOK_PATH%
echo.
Post-checkout file:
./RestoreB.bat
I think it happens because TeamCity doesn't run the 'git checkout' command and runs 'git reset --hard' instead. Could you please explain how you reference a repository from the main repository, maybe you can achieve what you want to do without hooks.
Thank you, I didn't know TeamCity doesn't run 'git checkout'. We can run RestoreB.bat in build step before build. We just want to know why it is not working.