From: Erik Mackdanz Date: Wed, 6 Nov 2024 04:26:04 +0000 (+0000) Subject: support git post-receive hook X-Git-Url: https://git.humopery.space/?a=commitdiff_plain;h=a8ec5ef9e9cb0d8f38e924a99a609e0e24a3067c;p=private%2Fbuildbot-default.git support git post-receive hook --- diff --git a/master.cfg b/master.cfg index 7319b5b..5dfd2ae 100644 --- a/master.cfg +++ b/master.cfg @@ -3,6 +3,7 @@ from buildbot.plugins import changes, reporters, schedulers, secrets, steps, util, worker from buildbot.changes.filter import ChangeFilter from buildbot.changes.gitpoller import GitPoller +from buildbot.changes.pb import PBChangeSource from buildbot.config.builder import BuilderConfig from buildbot.steps.source.git import Git from buildbot.steps.shell import ShellCommand @@ -38,6 +39,11 @@ c['protocols'] = {'pb': { ####### CHANGESOURCES c['change_source'] = [] + +c['change_source'].append(PBChangeSource( + port=9444, + user="local-post-receive", + passwd=Secret("local-post-receive.pass"))) c['change_source'].append(GitPoller( 'https://framagit.org/medoc92/npupnp.git', project='npupnp', @@ -390,6 +396,26 @@ c['builders'].append(BuilderConfig( workernames=["carbon-worker"], factory=factory)) +####### hook-test + +localrepo='/usr/src/bare/hook-test.git' +c['schedulers'].append(SingleBranchScheduler( + name="hook-test", + change_filter=ChangeFilter(project="hook-test"), + treeStableTimer=None, + builderNames=["hook-test"])) +factory = BuildFactory() +factory.addStep(Git(repourl='lin0:'+localrepo,branch='main')) +factory.addStep(ShellCommand( + name="echo something", + command=["echo","hello"], + haltOnFailure=True)) +c['builders'].append(BuilderConfig( + name="hook-test", + tags=["hook-test"], + workernames=["carbon-worker"], + factory=factory)) + ####### PROJECT IDENTITY c['title'] = "Humopery CI" diff --git a/post-receive b/post-receive new file mode 100755 index 0000000..b4e743d --- /dev/null +++ b/post-receive @@ -0,0 +1,27 @@ +#!/bin/bash + +# To prepare a git hook: +# - copy this file into the bare repo's hooks dir (with +x) +# - 'pip install future' within the venv +# - adjust paths below, if using from some other machine +# - set --auth below to the real password + +# PBChangeSource doc: https://docs.buildbot.net/current/manual/configuration/changesources.html#pbchangesource +# The doc makes it sound like the worker port (9989 TLS) must be used but it doesn't work +# This method doesn't use TLS so not very secure. I think git_buildbot.py just doesn't support TLS + +# Note the same PBChangeSource can be used for: +# buildbot sendchange --project foo --master 127.0.0.1:9444 --auth local-post-receive:XXXXXXXXXXX --who erik + +source /var/lib/buildmaster/src/buildbot/.venvpython3/bin/activate +# echo $VIRTUAL_ENV +# echo $PATH +# while read line; do echo $line; done + +export GIT_DIR + +exec /var/lib/buildmaster/src/buildbot/master/contrib/git_buildbot.py \ + --master bb.humopery.space:9444 \ + --username local-post-receive \ + --auth XXXXXXXXXXXXXXXX \ + --project hook-test