Hi all,
I wish to create a custom groovy pre-receive hook to intercept git push operation + push options sent by this syntax for example:
>>> git push -o topic=master
I easily wrote a bash script to read these options, as described in this link:
https://git-scm.com/docs/githooks#post-receive
and placed it in the Bitbucket server repository directory: <BITBUCKET_HOME>/shared/data/repositories/<REPO_ID>/hooks/pre-receive.d.
This script prints GIT_PUSH_OPTION_COUNT, GIT_PUSH_OPTION_0:
echo $GIT_PUSH_OPTION_COUNT
echo $GIT_PUSH_OPTION_0
I would like to achieve the same behavior using JAVA/GROOVY with Bitbucket API, and read the GIT_PUSH_OPTIONS variables. I found that I can use scmHookDetails.getEnvironment() class to read these variables, however I saw in the API changelog that this class is deprecated in Bitbucket v6 (which we plan to upgrade soon):
https://developer.atlassian.com/server/bitbucket/reference/api-changelog/
What are my other options? Can I use System.getenv to get all groovy environment variables instead?
Thanks!!
Yael