bitbucketserver

package
v1.5.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bitbucketserver is a small client for Bitbucket Server and Data Center (REST /rest/api/1.0), authenticated with a personal access token. It is unrelated to Bitbucket Cloud (internal/bitbucketapp): different API, auth and webhook format. Repositories are addressed as "PROJECT/slug".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitRepo

func SplitRepo(repo string) (project, slug string, err error)

SplitRepo parses "PROJECT/slug" into its two keys.

Types

type Account

type Account struct {
	ID    string
	Login string
}

Account is the user behind a personal access token.

type Branch

type Branch struct {
	Name      string
	CommitSHA string
}

Branch is one branch and its head commit.

type Client

type Client struct {
	HTTP *http.Client
}

Client talks to one Bitbucket Server instance per call; the instance URL is an argument because every install is self-hosted.

func NewClient

func NewClient() *Client

NewClient returns a Client on the SSRF-guarded HTTP client, since instance URLs are operator supplied.

func (*Client) CreateRepoWebhook

func (c *Client) CreateRepoWebhook(ctx context.Context, instanceURL, token, repo, hookURL, secret string) error

CreateRepoWebhook registers a repo:refs_changed webhook on "PROJECT/slug". The secret makes Bitbucket sign each delivery with X-Hub-Signature (sha256=).

func (*Client) CurrentUser

func (c *Client) CurrentUser(ctx context.Context, instanceURL, token string) (Account, error)

CurrentUser resolves the token's user: whoami returns the login as plain text, then the users endpoint supplies the stable numeric id.

func (*Client) DefaultBranch

func (c *Client) DefaultBranch(ctx context.Context, instanceURL, token, repo string) (string, error)

DefaultBranch returns the repository's default branch, or "" for an empty repository.

func (*Client) DeleteRepoWebhook

func (c *Client) DeleteRepoWebhook(ctx context.Context, instanceURL, token, repo, hookURL string) error

DeleteRepoWebhook removes this control plane's webhook pointing at hookURL; it is a no-op when none exists.

func (*Client) GetRepo

func (c *Client) GetRepo(ctx context.Context, instanceURL, token, repo string) (Repo, error)

GetRepo looks up "PROJECT/slug" and asks the server for its default branch.

func (*Client) ListBranches

func (c *Client) ListBranches(ctx context.Context, instanceURL, token, repo string) ([]Branch, error)

ListBranches lists the branches of "PROJECT/slug".

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context, instanceURL, token string, opts gitprovider.ListOptions) ([]Repo, gitprovider.ListResult, error)

ListRepos lists repositories the token can see, following nextPageStart until the last page or MaxItems.

type Repo

type Repo struct {
	FullName      string
	Name          string
	Private       bool
	DefaultBranch string
	CloneURL      string
	WebURL        string
}

Repo is one repository, reduced to what the picker and source setup need.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL