I wrote a script (perl) to perform this task using Bitbucket-API.
What I basically did within my script
Just a little basic scripting ...
Hi Kilian, Thanks for writing back.
Even I tried to make things work but rest-api command is not working for me and I am all stuck.
Can you please share your perl script for me to have a look. I would appreciate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Anyone have any idea, why below rest-api is not working. I am trying to enable a hook called sscc for one the repository using rest-api. It gave me an error.
curl -sS -X PUT -u username:pass http://<hostname>:7990/rest/api/1.0/projects/ABC/repos/sample_repo/settings/hooks/se.bjurr.sscc.sscc/enabled | jq -r
OUTPUT:
{
"errors": [
{
"context": null,
"message": "An error occurred while processing the request. Check the server logs for more information.",
"exceptionName": null
}
]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Akul Bhatnagar - sorry I'm not allowed to share my code due to our policies ;-/
Just an guess, why your curl request might not work: your hook-key "se.bjurr.sscc.sscc" looks strange in comparison to what I use: "com.atlassian.bitbucket.server.bitbucket-bundled-hooks:force-push-hook" (mind the colon)
Try to get the available hooks first (using https://developer.atlassian.com/static/rest/bitbucket-server/4.5.2/bitbucket-rest.html#idp2911664) and check whether the hook key you used is correct
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried for number of hooks with correct add-on key which their developers have mentioned, but still the same error.
<confused>
Can you share your curl command with me, hope that'll not be considered as a code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't use curl very often - for testing I use a REST-client addon for Google Chrome (Postman: https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop).
I just used my standard Bitbucket authorization data and did a simple http GET:
chrome_2016-04-20_08-25-56.png
-----
Edit: Just tried a simple GET via curl (same REST-call as above):
curl -u user:secret http://bitbucket.vitronic.de:7990/rest/api/1.0/projects/ABC/repos/sample_repo/settings/hooks/com.atlassian.bitbucket.server.bitbucket-bundled-hooks:force-push-hook
This worked fine and returned the same result as above
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I saw your addon key and got a question
com.atlassian.bitbucket.server.bitbucket-bundled-hooks:force-push-hook
:force-push-hook – is this part of key OR you have appended it knowingly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Running a HTTP Get request on http://bitbucket.vitronic.de:7990/rest/api/1.0/projects/ABC/repos/sample_repo/settings/hooks gives a full list of available hooks for the given repository. (Thats what I meant when I wrote above: Try to get the available hooks first (using https://developer.atlassian.com/static/rest/bitbucket-server/4.5.2/bitbucket-rest.html#idp2911664) and check whether the hook key you used is correct)
Looking at this list shows that :force-push-hook IS part of the key ....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Having a look at my available hooks, I noticed that we've also got your desired SSCC hook available. The correct key seems to be:
se.bjurr.sscc.sscc:pre-receive-repository-hook
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I wanted to share some additional information on the above, had some trouble initially figuring out how to enable/configure hook settings. In my case we are using 'Yet Another Commit Checker' and our organisation wants to enable enable 'reqireJira Issue' enabled.
I used the below command to achieve it:
curl -k --user user:secret -X PUT -H "Accept: application/json" -H "Content-Type: application/json" -X PUT https://bitbucket.DOMAIN.com/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/com.isroot.stash.plugin.yacc:yaccHook/enabled -d '{"requireJiraIssue": true}'
com.isroot.stash.plugin.yacc:yaccHook - is the {hookKey}
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sai N, thanks for the very useful information. I am very curious about whether the 'reqireJira Issue' is defined by the 'com.isroot.stash.plugin.yacc:yaccHook' plugin?
And I want to enable a plugin 'com.ngs.stash.externalhooks.external-hooks:external-merge-check-hook' which needed some params, do you know which **API** I can use to config it(not from the bitbucket UI)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.