Git post-receive hook using python (on Windows)

Hi,
I created a post-receive hook using python.

I put the hook into the hooks folder of a remote repository on the same machine where I run SCM Manager application. Operating System: Windows 2016 Server.
The hook works fine.

When I put the same hook into a SCM hooks repository:
repository
+ data
++ hooks
It doesn’t work; I receive the following error:

remote: error: [SCM] failure during file hook execution

from log:

2024-05-21 16:58:51.418 [qtp1288354730-103] [FdUDQAhyNi] ERROR sonia.scm.web.GitFileHook - failure during file hook execution
java.io.IOException: Cannot run program “D:\SCM-Manager\repositories\72UD2QABi3E\data\hooks\post-receive” (in directory “D:\SCM-Manager\repositories\72UD2QABi3E\data”): CreateProcess error=193, %1 is not a valid Win32 application

but, if I create a .bat file: post-receive.bat:

@echo off
echo Hello, World!
pause

It works.

Can you please help me?

Thanks,
Paolo

Hi,
I solved it by my own with a workaround. I created a batch calling the python file.

post-receive.bat:
@echo off
python <path>\hooks\post-receive.py %*

post-receive.py
…python code…

Paolo

1 Like

Hey @paolongit

thank you for sharing your solution with the community :heart: