Gitea
Description
The gitea scm plugin clones a repository hosted on a Gitea instance and pushes changes back to it. It is referenced by a resource through its scmid, as described on the "SCM" page.
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 gitea/pullrequest, documented on the "Gitea 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. default: main remark:
example:
| |
| commitmessage | object | “commitmessage” defines the settings used to generate commit messages. remark:
| |
| body | string | “body” defines the conventional commit body. default: empty, which means the body is generated by Updatecli. remark:
| |
| deprecatedtitle | string | “title” is ignored. deprecated:
| |
| footers | string | “footers” defines the conventional commit footers. default: empty remark:
| |
| hidecredit | boolean | “hidecredit” defines whether the Updatecli credit line is left out of the commit message body. default: false remark:
| |
| scope | string | “scope” defines the conventional commit scope. default: empty remark:
| |
| squash | boolean | “squash” defines whether the commits are squashed into a single commit. default: false remark:
| |
| 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 conventional commit type, such as “chore”, “fix” or “feat”. default: chore remark:
| |
| depth | integer | “depth” defines the depth used when cloning the git repository. default: empty, which means a full clone. remark:
example:
| |
| directory | string | “directory” defines the local path where the git repository is cloned. default:
a directory under the Updatecli temporary directory, such as
“/tmp/updatecli/gitea/ remark:
| |
| string | “email” defines the email address used to author commits. default: updatecli-bot@updatecli.io | ||
| force | boolean | “force” defines whether Updatecli runs default: true remark:
| |
| gpg | object | “gpg” defines the GPG key and passphrase used to sign commits. | |
| passphrase | string | “passphrase” defines the passphrase that unlocks “signingkey”. | |
| signingkey | string | “signingkey” defines the armored GPG private key used to sign commits. default: empty, which means commits are not signed. remark:
| |
| owner | string | “owner” defines the owner of the repository. | |
| repository | string | “repository” defines the name of the repository. | |
| singlebranch | boolean | “singlebranch” defines whether Updatecli clones and fetches only the configured branch, instead of every branch, tag and other reference of the remote. default: false remark:
| |
| submodules | boolean | “submodules” defines whether Updatecli clones the git submodules of the repository. default: true | |
| token | string | “token” defines the credential used to authenticate with the Gitea API. remark:
| |
| url | string | “url” defines the Gitea url to interact with. remark:
example:
| |
| user | string | “user” defines the name used to author commits. default: updatecli-bot | |
| username | string | “username” defines the username used to authenticate with the Gitea API. remark:
| |
| workingbranch | boolean | “workingbranch” defines whether Updatecli pushes changes to a temporary working branch based on “branch”, instead of pushing to “branch” directly. default: true | |
| workingbranchprefix | string | “workingbranchprefix” defines the prefix of the working branch name. default: updatecli remark:
| |
| workingbranchseparator | string | “workingbranchseparator” defines the separator between the parts of the working branch name. default: _ |
url, owner, and repository are mandatory. A missing owner or repository aborts the run with wrong gitea configuration; a missing url with wrong configuration.
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. The directory description also mentions a github path; on this plugin the default is under gitea, as described below. |
Authentication
url points at your instance, with or without a scheme (try.gitea.io and https://try.gitea.io are equivalent, and https:// is assumed when none is given).
token is used both for the Gitea API and, together with username, as the HTTP credentials for git operations. Keep it out of the manifest:
url: "try.gitea.io"
username: '{{ requiredEnv "GITEA_USERNAME" }}'
token: '{{ requiredEnv "GITEA_TOKEN" }}'The token needs read access for a source or a condition, and write access to the repository for a target. Reading from a public repository works without any credential.
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. Set them to an identity your Gitea instance recognises if you want the commits attributed to an account.
Clone behavior
Left unset, directory defaults to <tmp>/updatecli/gitea/<owner>/<repository> - /tmp/updatecli/gitea/olblak/updatecli-mirror on Linux. 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).
On a repository with a large number of refs, singleBranch is the option that pays off: it skips the fetch that otherwise mirrors every branch, tag, and pull request ref from the remote. It only applies when branch is set. See Large repositories for a full manifest.
Example
Default
# updatecli.yaml
---
name: Test Gitea scm
scms:
gitea:
kind: gitea
spec:
url: "try.gitea.io"
owner: "olblak"
repository: "updatecli-mirror"
branch: main
sources:
license:
name: Retrieve license file content
kind: file
scmid: gitea
spec:
file: LICENSE
Large repositories
# updatecli.yaml
---
name: Test Gitea scm optimized for large repositories
scms:
gitea:
kind: gitea
spec:
url: "try.gitea.io"
owner: "olblak"
repository: "updatecli-mirror"
branch: main
singleBranch: true
sources:
license:
name: Retrieve license file content
kind: file
scmid: gitea
spec:
file: LICENSE