On this page
Stash Branch
| source | condition | target |
|---|---|---|
✔ | ✔ | ✗ |
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 highestrelease/x.y.- condition
Tests that
branchexists 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
| Name | Type | Description | Required |
|---|---|---|---|
| branch | string | [C] Branch specifies the branch name | |
| owner | string | [S][C] Owner specifies repository owner | |
| password | string | “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 For more information, about a SOPS file, please refer to the following documentation: https://github.com/getsops/sops | |
| repository | string | [S][C] Repository specifies the name of a repository for a specific owner | |
| token | string | “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 For more information, about a SOPS file, please refer to the following documentation: https://github.com/getsops/sops | |
| url | string | “url” specifies the default stash url in case of Bitbucket Server | |
| username | string | “username” specifies the username used to authenticate with Bitbucket Server API | |
| versionfilter | object | [S] VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest. | |
| kind | string | specifies the version kind such as semver, regex, or latest | |
| pattern | string | specifies 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 | |
| regex | string | specifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used. | |
| replaceall | object | replaceAll 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. | |
| strict | boolean | strict enforce strict versioning rule. Only used for semantic versioning at this time |
url, owner and repository are mandatory.
urlThe Bitbucket Server instance, e.g.
https://stash.example.com. This is a self-hosted product, so there is no default.ownerThe project key or user the repository belongs to.
branchCondition only - the branch being checked.
versionfilterSource 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: myrepopassword 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/.*'Links
The
stashscm - to clone and push