Is there an interface (Java) to see if a hook is enabled/disabled? I only need access inside of it's own class.
Is this going to be a Catch-22 scenario, where the class doesn't fire if the hook is disabled?
Calling the REST endpoint is basically just doing a HTTP request. If you're on linux/mac you can use curl to do that:
curl -X GET -u <repo-admin-user>http://stash.example.com/rest/api/latest/projects/<projectKey>/repos/<repositorySlug>/settings/hooks
And to enable/disable a hook:
curl -X PUT -u <repo-admin-user>http://stash.example.com/rest/api/latest/projects/<projectKey>/repos/<repositorySlug>/settings/hooks/<hookKey>/enabled/true
Yes. I got the hook key from the first command. However, the following does not seem to work. I am still missing something.
I am getting a error code 404.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri: http://ets-test-cmteam:7990/rest/api/latest/projects/RNDAP/repos/ap-eclipsetools/settings/hooks/com.atlassian.stash.stash-bundled-hooks:force-push-hook/enabled/true</message></stat
Ah apologies, I read our REST documentation wrong. The /true suffix is the problem. The command to enable a hook is
curl -X PUT -u repo-admin-user http://ets-test-cmteam:7990/projects/RNDAP/repos/ap-eclipsetools/settings/hooks/com.atlassian.stash.stash-bundled-hooks:force-push-hook/enabled
To disable the hook, send a DELETE instead:
curl -X DELETE -u repo-admin-user http://ets-test-cmteam:7990/projects/RNDAP/repos/ap-eclipsetools/settings/hooks/com.atlassian.stash.stash-bundled-hooks:force-push-hook/enabled
Enable or disable hook works fine with REST API. How about change value?
I'm using an external pre-receive hook with parameters. Can I change a parameter value via rest api?
How I can set new value, for example: params":"-M firstname.lastname@example.org" ?
Thanks in advance.
You need to do a PUT by passing the parameters
I think this should solve your problem.
Look into this documentation from Atlassian for more info.
Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster ! While we’re all excited about the new improvements to Bitbucket ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events