Package: buildbot-gitea
Buildbot Gitea PluginThis plugin for buildbot adds integration support with gitea, featuring push hooks, commit status updates and a change source.Installationpip install buildbot_giteaThis installs itself into the plugin discovery of buildbot, so no extra imports are required to get buildbot to find the plugin.ConfigurationThe following configuration shows how the different parts of the plugin can be set-up in the buildbot master.cfg:frombuildbot.pluginsimport*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 debuggingreporters.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
subclassbuildbot_gitea.webhook.GiteaHandlerto add supports for other events,
and then use your subclass by setting theclassparameter:# myhook.pyfrombuildbot_gitea.webhookimportGiteaHandlerclassMyGiteaHook(GiteaHandler)defprocess_whatever(self,payload,event_type,codebase):# This should be a list of dictschanges=[]returnchanges# master.cfgfrommyhookimportMyGiteaHookc['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).ParametersChange HookThe change hook is set as part of thewwwsection in thechange_hook_dialectsnamedgitea.ParameterDescriptionsecretThe secret, which needs to be set in giteaonlyIncludePushCommitA 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.onlyMergeablePullRequestIgnore pull request if not mergeable. If this is true, only mergeable pull requests will be processed.classSet 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:ParameterValueTarget URLhttps://example.com/change_hook/gitea/HTTP MethodPOSTPOST Content Typeapplication/jsonSecretThesecretfrom aboveChange SourceThe 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 giteachange_hookand have it send pull request updates in order to be able  to handle pull requests.The parameters for this are identical to the defaultgitstep from buildbot. It just uses information provided by the giteachange_hookto be able to handle pull requests.ReporterThe 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.TheGiteaStatusPushis added to theservicessection of the global master config.The parameters are as follows:ParameterValueURLThe URL to the gitea instance.tokenGenerate an access token in the profile you want the buildbot to impersonate. Make sure the account in gitea has access to the repositories.contextRenderableThe context is an identifier for this status, allowing to identify from which builder this came, defaults toInterpolate('buildbot/%(prop:buildername)s')context_prRenderableThe context message to use, when building on a pull request, allowing to identify from which builder this came, defaults toInterpolate('buildbot/pull_request/%(prop:buildername)s')warningAsSuccessTreat warnings as build as success to set in the build status of gitea. If false, warnings will be displayed as warnings.verbosePerform verbose outputAuthenticationGitea supports OAuth2 authentication so it is possible to have buildbot communicate to Gitea to authenticate the user../master.cfgfrombuildbot.pluginsimportutilc['www']['auth']=util.GiteaAuth(endpoint="https://your-gitea-host",client_id='oauth2-client-id',client_secret='oauth2-client-secret')ParameterValueendpointThe URL to your Gitea app. Something likehttps://gitea.example.com/client_idThe OAuth2 Client IDGUID, can be aSecret.client_secretThe OAuth2 Client Secret provided, when creating the OAuth application in gitea. Can be aSecret.Resources:Gitea OAuth2 Provider documentationBuildbot OAuth2 documentation