Buildbot Gitea Plugin
This plugin for buildbot adds integration support with gitea, featuring push hooks, commit status updates and a change source.
Installation
pip install buildbot_gitea
This installs itself into the plugin discovery of buildbot, so no extra imports are required to get buildbot to find the plugin.
Configuration
The following configuration shows how the different parts of the plugin can be set-up in the buildbot master.cfg:
from buildbot.plugins import *
c = BuildbotMasterConfig = {}
c['www'] = {
'change_hook_dialects': {
'gitea': {
'secret': '<SecretToEnterInGitea>',
'onlyIncludePushCommit': True
}
},
}
c['services'] = [
# Report status back to gitea, verbose flag enables verbose output in logging for debugging
reporters.GiteaStatusPush(
'https://example.com', "SECRET", verbose=True)
]
buildFactory = util.BuildFactory()
factory.addStep(steps.Gitea(
repourl="ssh://git@example.com/example_user/example_project.git",
mode='incremental',
workdir="build",
branch="master",
codebase='example_codebase',
progress=True,
logEnviron=False,
))
The webhook currently supports pushes and pull requests by default, but you can
subclass buildbot_gitea.webhook.GiteaHandler to add supports for other events,
and then use your subclass by setting the class parameter:
# myhook.py
from buildbot_gitea.webhook import GiteaHandler
class MyGiteaHook(GiteaHandler)
def process_whatever(self, payload, event_type, codebase):
# This should be a list of dicts
changes = []
return changes
# master.cfg
from myhook import MyGiteaHook
c['www'] = {
'change_hook_dialects': {
'gitea': {
'class': MyGiteaHook,
# ...
}
}
}
Note that the handlers need to be named according to the scheme:
process_{event} (e.g., process_create, etc).
Parameters
Change Hook
The change hook is set as part of the www section in the change_hook_dialects named gitea.
| Parameter | Description |
|---|---|
secret |
The secret, which needs to be set in gitea |
onlyIncludePushCommit |
A push may have more than one commit associated with it. If this is true, only the newest (latest) commit of all received will be added as a change to buildbot. If this is set to false, all commits will inside the push will be added. |
onlyMergeablePullRequest |
Ignore pull request if not mergeable. If this is true, only mergeable pull requests will be processed. |
class |
Set this if you want to use your own handler class (see above for details) |
In gitea in your project or organization and add a new webhook of type gitea. Set the parameters as follows:
| Parameter | Value |
|---|---|
| Target URL | https://example.com/change_hook/gitea/ |
| HTTP Method | POST |
| POST Content Type | application/json |
| Secret | The secret from above |
Change Source
The change source is part build step to clone a gitea repository. It includes features to build a pull request, if the pull request can be merged without conflicts. This needs to be used in conjunction with a gitea change_hook and have it send pull request updates in order to be able to handle pull requests.
The parameters for this are identical to the default git step from buildbot. It just uses information provided by the gitea change_hook to be able to handle pull requests.
Reporter
The reporter sets the commit status of a commit inside of gitea, so in gitea a small icon will be displayed next to the commit message, indicating the build status.
The GiteaStatusPush is added to the services section of the global master config.
The parameters are as follows:
| Parameter | Value |
|---|---|
| URL | The URL to the gitea instance. |
token |
Generate an access token in the profile you want the buildbot to impersonate. Make sure the account in gitea has access to the repositories. |
context |
Renderable The context is an identifier for this status, allowing to identify from which builder this came, defaults to Interpolate('buildbot/%(prop:buildername)s') |
context_pr |
Renderable The context message to use, when building on a pull request, allowing to identify from which builder this came, defaults to Interpolate('buildbot/pull_request/%(prop:buildername)s') |
warningAsSuccess |
Treat warnings as build as success to set in the build status of gitea. If false, warnings will be displayed as warnings. |
verbose |
Perform verbose output |
Authentication
Gitea supports OAuth2 authentication so it is possible to have buildbot communicate to Gitea to authenticate the user.
./master.cfg
from buildbot.plugins import util
c['www']['auth'] = util.GiteaAuth(
endpoint="https://your-gitea-host",
client_id='oauth2-client-id',
client_secret='oauth2-client-secret')
| Parameter | Value |
|---|---|
endpoint |
The URL to your Gitea app. Something like https://gitea.example.com/ |
client_id |
The OAuth2 Client ID GUID, can be a Secret. |
client_secret |
The OAuth2 Client Secret provided, when creating the OAuth application in gitea. Can be a Secret. |
Resources:
Metadata
Release files for buildbot-gitea 1.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| buildbot-gitea-1.8.0.tar.gz | 12.0 kB | Without provenance | Details for buildbot-gitea-1.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| buildbot_gitea-1.8.0-py3-none-any.whl | Python 3 | none | any | Details for buildbot_gitea-1.8.0-py3-none-any.whl |
Total release size: 22.9 kB
Release files / buildbot-gitea-1.8.0.tar.gz
| Download URL | buildbot-gitea-1.8.0.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd87082cfa78d90b90c9f108ce660a57dbd67f8eec040408f0538a26567ad320
|
|
BLAKE2b-256 checksum How to use checksums |
d32dd93e60487fdb4ca5c2aa824ce8a2476c4e407f07b2b38b48280fd19d7e64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.2 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.8
|
Release files / buildbot_gitea-1.8.0-py3-none-any.whl
| Download URL | buildbot_gitea-1.8.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
05404ff325546dbecdfe05c0ce7970ee77c02ba22b79158e67bf90ea025e0e06
|
|
BLAKE2b-256 checksum How to use checksums |
4bb8b4729f2c072b9d24cbc8468a86991ee024ee877f53f8e7a5f90571b9b6a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.2 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.8
|
Security for buildbot-gitea 1.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.