sourceconditiontarget

Description

The stash/branch resource queries the branches of a repository hosted on Bitbucket Server (the product formerly called Stash and now Bitbucket Data Center).

source

Returns the branch matching versionfilter, which is how you follow a release branch such as the highest release/x.y.

condition

Tests that branch exists in the repository.

target

Not supported - a target fails with target not supported for the plugin stash branch. Say so on the issue tracker if you would use one.

Note
An scm is accepted but ignored, logging scm not supported, ignoring. The lookup always goes to the Bitbucket Server API.

Parameters

NameTypeDescriptionRequired
branchstring[C] Branch specifies the branch name
ownerstring[S][C] Owner specifies repository owner
passwordstring

“password” specifies the credential used to authenticate with Bitbucket Server API, it must be combined with “username”

remark: A token is a sensitive information, it’s recommended to not set this value directly in the configuration file but to use an environment variable or a SOPS file.

The value can be set to {{ requiredEnv "BITBUCKET_TOKEN"}} to retrieve the token from the environment variable BITBUCKET_TOKEN or {{ .bitbucket.token }} to retrieve the token from a SOPS file.

For more information, about a SOPS file, please refer to the following documentation: https://github.com/getsops/sops

repositorystring[S][C] Repository specifies the name of a repository for a specific owner
tokenstring

“token” specifies the credential used to authenticate with Bitbucket Server API

remark: A token is a sensitive information, it’s recommended to not set this value directly in the configuration file but to use an environment variable or a SOPS file.

The value can be set to {{ requiredEnv "BITBUCKET_TOKEN"}} to retrieve the token from the environment variable BITBUCKET_TOKEN or {{ .bitbucket.token }} to retrieve the token from a SOPS file.

For more information, about a SOPS file, please refer to the following documentation: https://github.com/getsops/sops

urlstring“url” specifies the default stash url in case of Bitbucket Server
usernamestring“username” specifies the username used to authenticate with Bitbucket Server API
versionfilterobject[S] VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest.
    kindstringspecifies the version kind such as semver, regex, or latest
    patternstringspecifies the version pattern according the version kind for semver, it is a semver constraint for regex, it is a regex pattern for time, it is a date format
    regexstringspecifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used.
    replaceallobjectreplaceAll applies a regex replacement to version strings before filtering. This is useful for transforming versions (e.g., curl-8_15_0 to curl-8.15.0) before regex extraction.
    strictbooleanstrict enforce strict versioning rule. Only used for semantic versioning at this time

url, owner and repository are mandatory.

url

The Bitbucket Server instance, e.g. https://stash.example.com. This is a self-hosted product, so there is no default.

owner

The project key or user the repository belongs to.

branch

Condition only - the branch being checked.

versionfilter

Source only. See the "Version Filtering" page.

Authentication

Credentials are either a token or a username and password pair, both sensitive, so read them from the environment or a SOPS file rather than writing them into the manifest:

spec:
  url: https://stash.example.com
  token: '{{ requiredEnv "BITBUCKET_TOKEN" }}'
  owner: PROJECTKEY
  repository: myrepo

password must be combined with username. Reading a public repository needs no credential at all.

Example

# updatecli.yaml
sources:
  latestReleaseBranch:
    name: Get the latest release branch
    kind: stash/branch
    spec:
      url: https://stash.example.com
      token: '{{ requiredEnv "BITBUCKET_TOKEN" }}'
      owner: PROJECTKEY
      repository: myrepo
      versionfilter:
        kind: regex
        pattern: 'release/.*'