Check first the actual environment used by SourceTree.
For instance, in this bug report (yes, For Mac, not Windows, but the general point remains valid):
Have a look at SRCTREE-3583
.
Sourcetree is most likely not picking up your script because it is launched as a service and will not pick up your changes to the PATH.
You need to extend the PATH that your apps see, checkout "Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra/Mojave?" (mentioned in the issue) or search on how to extend PATH
in OS X.
This is a Mac-specific issue, but in your case, you need to open a terminal from SourceTree, type "env
", and check your environment variables compared to a regular CMD session where the filter works.
Not only the PATH should include your script, but it should also include ruby, in order to execute your script.