bitbucketserver

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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