Bitbucket Server (Stash)
Description
The stash scm plugin clones a repository hosted on a self-managed Bitbucket Data Center / Server instance (historically named Stash) and pushes changes back to it. It is referenced by a resource through its scmid, as described on the "SCM" page.
For repositories on bitbucket.org, use the bitbucket plugin instead.
Its behavior depends on the stage referencing it:
- source and condition
The repository is cloned and the resource works on the files from the branch defined by
branch. Nothing is pushed.- target
Updatecli creates a working branch based on
branch, commits the changes to it, and pushes that branch. Thebranchvalue itself is left untouched.
Important | This plugin does not open pull requests. Pushing a working branch and opening a pull request are two distinct steps: the pull request comes from an actions block of kind stash/pullrequest, documented on the "Bitbucket Server Pull Request" page. Without such an action, the branch is pushed and nothing else happens. |
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| branch | string | “branch” defines the git branch to work on. compatible:
default: main remark: depending on which resource references the Stash scm, the behavior will be different. If the scm is linked to a source or a condition (using scmid), the branch will be used to retrieve file(s) from that branch. If the scm is linked to target then Updatecli creates a new “working branch” based on the branch value.
The working branch created by Updatecli looks like “updatecli_ | |
| commitmessage | object | “commitMessage” is used to generate the final commit message. compatible:
remark: it’s worth mentioning that the commit message settings is applied to all targets linked to the same scm. | |
| body | string | body defines the commit body of the commit message as defined by the conventional commit specification. More information on -> https://www.conventionalcommits.org/en/ default: none | |
| deprecatedtitle | string | DeprecatedTitle is deprecated and will be ignored. The commit title is now always generated from the target name or description. | |
| footers | string | footers defines the footer of the commit message as defined by the conventional commit specification. More information on -> https://www.conventionalcommits.org/en/ default: none | |
| hidecredit | boolean | hideCredit defines if updatecli credits should be displayed inside commit message body please consider sponsoring the Updatecli project if you want to disable credits. -> https://github.com/updatecli/updatecli default: false | |
| scope | string | scope defines the scope of the commit message as defined by the conventional commit specification. More information on -> https://www.conventionalcommits.org/en/ default: none | |
| squash | boolean | squash defines if the commit should be squashed default: false important: if squash is set to true, then it’s highly recommended to set the commit body to a meaningful value as all other commit information will be lost during the squash operation. if body is not set, then the commit title/message will be generated based on the most recent commit message of the squashed commits. The commit title is always generated from the target name or description. | |
| title | string | Title is the parsed commit message title (not configurable via YAML). The title is automatically generated from the target name or description. | |
| type | string | type defines the type of commit message such as “chore”, “fix”, “feat”, etc. as defined by the conventional commit specification. More information on -> https://www.conventionalcommits.org/en/ default:
| |
| depth | integer | Depth defines the depth used when cloning the git repository. Default: disabled (full clone) Remark: When using a shallow clone (depth greater than 0), Updatecli is not able to retrieve the full git history. This may cause some issues when Updatecli tries to push changes to the remote repository. In that case, you may need to set the force option to true to force push changes to the remote repository. | |
| directory | string | “directory” defines the local path where the git repository is cloned. compatible:
remark: Unless you know what you are doing, it is recommended to use the default value. The reason is that Updatecli may automatically clean up the directory after a pipeline execution. default:
The default value is based on your local temporary directory like: (on Linux)
/tmp/updatecli/stash/ | |
| string | “email” defines the email used to commit changes. compatible:
default: default set to your global git configuration | ||
| force | boolean | “force” is used during the git push phase to run compatible:
default: true remark: When force is set to true, Updatecli also recreate the working branches that diverged from their base branch. | |
| gpg | object | “gpg” specifies the GPG key and passphrased used for commit signing compatible: * scm | |
| passphrase | string | passphrase defines the gpg passphrase used to sign the commit message | |
| signingkey | string | signingKey defines the gpg key used to sign the commit message default: none | |
| owner | string | “owner” defines the owner of a repository. compatible: * scm | |
| 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 | repository specifies the name of a repository for a specific owner. compatible: * scm | |
| submodules | boolean | “submodules” defines if Updatecli should checkout submodules. compatible: * scm default: true | |
| 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 | |
| user | string | “user” specifies the user associated with new git commit messages created by Updatecli compatible: * scm | |
| username | string | “username” specifies the username used to authenticate with Bitbucket Server API | |
| workingbranch | boolean | “workingBranch” defines if Updatecli should use a temporary branch to work on.
If set to compatible: * scm default: true | |
| workingbranchprefix | string | WorkingBranchPrefix defines the prefix used to create a working branch. compatible:
default: updatecli remark: A working branch is composed of three components:
If WorkingBranchPrefix is set to ‘’, then
the working branch will look like “ | |
| workingbranchseparator | string | WorkingBranchSeparator defines the separator used to create a working branch. compatible:
default: “_” |
url, owner, and repository are mandatory. owner is the project key on Bitbucket Server, and the repository is cloned from <url>/scm/<owner>/<repository>.git (the /scm/ segment is added by Updatecli, so do not include it in url).
Note | The table is generated from the Updatecli JSON schema, refreshed by a bot after each release. A recently added parameter (currently singleBranch, which restricts clone and fetch to the configured branch) may work in the binary before it appears there. |
Authentication
url is your instance, with or without a scheme; https:// is assumed when none is given. A missing url aborts the run with wrong configuration.
Authentication is driven by token, an HTTP access token:
url: "https://bitbucket.example.com"
username: '{{ requiredEnv "BITBUCKET_USERNAME" }}'
token: '{{ requiredEnv "BITBUCKET_TOKEN" }}'With username set, the token is sent as HTTP basic credentials; on its own it is sent as a bearer token. Git operations always use username together with token.
Warning | The |
Working branch
For a target, the working branch is derived from three components joined by a separator:
<workingBranchPrefix><workingBranchSeparator><branch><workingBranchSeparator><pipelineID>With the defaults (updatecli and ), a pipeline based on main produces updatecli_main<pipelineID>, where pipelineID is a hash derived from the manifest - so the same pipeline reuses the same branch instead of piling up new ones. Characters git refuses in a ref are stripped, and the name is truncated to 255 characters. Setting workingBranchPrefix: "" gives <branch>_<pipelineID>.
branch defaults to main, with a warning in the logs when it is left unset.
Disabling the working branch
workingBranch: false makes Updatecli commit and push straight to branch. Since force defaults to true (meaning git push --force), that combination is refused unless force is also set explicitly:
Better safe than sorry.
Updatecli may be pushing unwanted changes to the branch "main".Set force: false to push without forcing, or force: true to acknowledge the force push. When force is true, Updatecli also recreates working branches that diverged from their base branch.
Tip | updatecli apply --clean-git-branches deletes, at the end of a run, the working branches that ended up identical to their base branch (those left behind by pipelines that had nothing to change). |
Commit message
Updatecli generates conventional commits. The commitMessage parameters (type, scope, body, footers, hideCredit, squash) shape the result.
The commit title always comes from the target’s name, or from its description when name is unset. It is capped at 72 characters minus the room taken by type and scope; the overflow moves into the body. With the default type chore:
Author: updatecli-bot <updatecli-bot@updatecli.io>
Date: Tue May 4 15:41:44 2021 +0200
chore: Update key "dependencies[0].version" from file "charts/jenkins/r...
... equirements.yaml"
Made with ❤️️ by updatecliSetting body replaces the generated body entirely, including that overflow. hideCredit: true drops the credit line. squash: true collapses the commits of the working branch into one (set body when you use it, since the individual messages are lost).
Warning |
|
Note | commitMessage applies to every target linked to the same scm. |
Commit signing and identity
gpg.signingkey takes an armored private GPG key and gpg.passphrase its passphrase. Both are secrets:
gpg:
signingkey: '{{ requiredEnv "GPG_SIGNING_KEY" }}'
passphrase: '{{ requiredEnv "GPG_PASSPHRASE" }}'user and email name the commit author, defaulting to updatecli-bot and updatecli-bot@updatecli.io.
Clone behavior
Left unset, directory defaults to <tmp>/updatecli/stash/<owner>/<repository> on your system temporary directory. Overriding it is rarely useful, as Updatecli may clean that directory up after a run.
submodulesDefaults to
true; set it tofalseto skip submodule checkout.depthNumber of commits to fetch. Unset means a full clone. A shallow clone leaves an incomplete history, which can break pushes;
force: trueis often needed alongside.singleBranchDefaults to
false, meaning every branch, tag, and ref is fetched.truefetches onlybranch(much faster on repositories with many refs, at the cost of Updatecli sometimes failing to notice an already published working branch and opening a duplicate pull request).
Example
# updatecli.yaml
---
name: Test Bitbucket Server (Stash) scm
scms:
stash:
kind: stash
spec:
# the "/scm/" path segment is added by Updatecli, don't include it here
url: "https://bitbucket.example.com"
# "owner" is the Bitbucket Server project key
owner: "olblak"
repository: "updatecli-mirror"
branch: "main"
# the credential goes in "token", "password" is not used by this plugin
username: '{{ requiredEnv "BITBUCKET_USERNAME" }}'
token: '{{ requiredEnv "BITBUCKET_TOKEN" }}'
sources:
license:
name: Retrieve license file content
kind: file
scmid: stash
spec:
file: LICENSE