Webhooks for Bitbucket that apply to all repos
Asked Answered
L

2

9

Our team has an account on Bitbucket and we have to configure webhooks for each repo. Is there a way to configure webhooks for all repos in once place instead of managing webhooks in each repo separately?

Alternatively, is there a way to use the bitbucket api to go through all the repos and update the webhooks for each one to the same setting?

Liber answered 24/5, 2019 at 23:41 Comment(0)
G
3

At the moment there is no way to configure a webhook globally over all projects. There is a Jira ticket for a default git hook configuration to provide this functionality. An update on Jan 2022 states that:

We understand that this capability is highly desirable especially in an enterprise environment. We will look into addressing it in the future, but at this moment we are unable to provide the exact timeline.

You can vote for it to give it more attention.

A workaround mentioned in another related ticket is:

Use /2.0/repositories/{username} to get a list of all repositories.
 
Use /2.0/repositories/{username}/{repo_slug}/hooks to add the webhook.

[Example:
$ curl -X POST -u credentials -H 'Content-Type: application/json'
  https://api.bitbucket.org/2.0/workspaces/my-workspace/hooks
  -d '
    {
      "description": "Webhook Description",
      "url": "https://example.com/",
      "active": true,
      "events": [
        "repo:push",
        "issue:created",
        "issue:updated"
      ]
    }'] 

using the Bitbucket API Repositories Resource and Bitbucket API Webhook Resource.

Greenbelt answered 8/3, 2022 at 12:29 Comment(0)
B
1

You'll need to use the API for it, but it's possible. https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams/%7Busername%7D/hooks/%7Buid%7D has the details for repos owned by a team, and https://developer.atlassian.com/bitbucket/api/2/reference/resource/users/%7Busername%7D/hooks/%7Buid%7D has them for repos owned by an individual user.

Bombard answered 25/5, 2019 at 0:32 Comment(1)
The links appear to redirect to no longer go to the correct documentation page. Instead they both go to a documentation page about "Authentication"Vulgarian

© 2022 - 2024 — McMap. All rights reserved.