You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Bitbucket Server API获取用户拥有的所有仓库?

How to Get All Repositories Associated with a Specific User in Bitbucket Server API

I get your frustration here—Bitbucket Server's API doesn't have a direct filter on the repos endpoint for user-owned repositories, and unlike some other platforms, it doesn't have a clear "owner" field tied directly to repositories. Let's break down how to work around this:

The Core Issue: Bitbucket Server's Permission Model

Bitbucket Server structures repositories under Projects, and user access is managed via permission grants rather than an explicit "owner" attribute. So to find repositories a user "owns" (we'll define this as having admin-level access, since that's the closest to ownership), we need to leverage the permissions API instead.

Step 1: Fetch the User's Repository Permissions

Use the users/{username}/permissions/repos endpoint to get all repositories the user has access to, along with their permission level:

curl -s -u YOUR-USERNAME:YOUR-PASSWORD -X GET https://bitbucket-server.domain.com/bitbucket/rest/api/1.0/users/TARGET-USERNAME/permissions/repos | jq '.values[]'

Each entry in the response will include a repository object with all the details you need (slug, name, links, etc.), plus the permission field indicating the user's access level (e.g., REPO_ADMIN, REPO_WRITE, REPO_READ).

Step 2: Filter for "Owner-Level" Repositories

If you want to narrow it down to repositories where the user has full control (the closest equivalent to "owning"), filter for REPO_ADMIN permissions with jq:

curl -s -u YOUR-USERNAME:YOUR-PASSWORD -X GET https://bitbucket-server.domain.com/bitbucket/rest/api/1.0/users/TARGET-USERNAME/permissions/repos | jq '.values[] | select(.permission == "REPO_ADMIN") | .repository'

Why Your Original Approach Didn't Work

The repos?name=apr-util call you tried only filters repositories by their name—it doesn't account for user permissions or association. That's why it returned a repository matching the name, but no user-related context.

内容的提问来源于stack exchange,提问作者Chris F

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:17:04