2019-11-22 10:59:53 +01:00
|
|
|
from buildbot.plugins import changes, schedulers, steps, util, worker
|
2019-09-06 16:49:06 +02:00
|
|
|
|
2019-11-22 10:59:53 +01:00
|
|
|
REPOURL_DOCKER = 'https://git.blackfinn.de/docker/bicycle-statistics.git'
|
|
|
|
REPOYRL_PYTHON = 'https://git.blackfinn.de/python/bicycle-statistics.git'
|
|
|
|
BRANCH = util.Property('branch', default='master')
|
|
|
|
|
|
|
|
COMMANDS = []
|
2020-09-29 15:44:16 +02:00
|
|
|
COMMANDS.append(['git', 'clone', '--branch', BRANCH, REPOURL_DOCKER])
|
|
|
|
COMMANDS.append(['docker', 'build', '--no-cache', '-t', 'bicycle-statistics', './bicycle-statistics'])
|
2019-11-22 10:59:53 +01:00
|
|
|
COMMANDS.append(['docker', 'rm', '-f', 'bicycle-statistics'])
|
|
|
|
COMMANDS.append(['docker', 'run', '-d', '-v',
|
|
|
|
'/srv/nextcloud/data/tkl/files/Bicycle:/bs_in', '-v',
|
|
|
|
'/srv/bicycle.blackfinn.de/data:/bs_out', '--name',
|
|
|
|
'bicycle-statistics', '--restart', 'always', 'bicycle-statistics'])
|
|
|
|
|
|
|
|
# Change sources
|
|
|
|
cs_bicycle_python = changes.GitPoller(project='bicycle-statistics-python',
|
|
|
|
repourl=REPOYRL_PYTHON,
|
|
|
|
branches=True, pollInterval=60)
|
|
|
|
|
|
|
|
cs_bicycle_docker = changes.GitPoller(project='bicycle-statistics-docker',
|
|
|
|
repourl=REPOURL_DOCKER,
|
|
|
|
branches=True, pollInterval=60)
|
|
|
|
|
|
|
|
|
|
|
|
# Factory
|
2019-09-06 16:49:06 +02:00
|
|
|
factory = util.BuildFactory()
|
2019-11-22 10:59:53 +01:00
|
|
|
for cmd in COMMANDS:
|
|
|
|
factory.addStep(steps.ShellCommand(command=cmd))
|
|
|
|
|
|
|
|
# Worker
|
2020-09-29 15:44:16 +02:00
|
|
|
bicycle_worker = worker.DockerLatentWorker('buildbot-worker-docker', 'pass',
|
|
|
|
docker_host='tcp://192.168.178.82:2375',
|
|
|
|
image='buildbot-worker-docker',
|
2019-11-22 10:59:53 +01:00
|
|
|
volumes=['/var/run/docker.sock:/var/run/docker.sock'])
|
|
|
|
|
|
|
|
# Builder
|
|
|
|
bicycle_builder = util.BuilderConfig(name='bicycle_statistics',
|
2020-09-29 15:44:16 +02:00
|
|
|
workernames=["buildbot-worker-docker"],
|
2019-11-22 10:59:53 +01:00
|
|
|
factory=factory)
|
|
|
|
|
|
|
|
# Schedulers
|
|
|
|
change_scheduler = schedulers.SingleBranchScheduler(name="bicycle_statistics",
|
|
|
|
change_filter=util.ChangeFilter(project=['bicycle-statistics-python',
|
|
|
|
'bicycle-statistics-docker']),
|
|
|
|
treeStableTimer=None, builderNames=["bicycle_statistics"])
|
|
|
|
|
|
|
|
force_scheduler = schedulers.ForceScheduler(name="force_bicycle-statistics", builderNames=["bicycle_statistics"])
|
|
|
|
|
|
|
|
|
|
|
|
def append(c):
|
|
|
|
c['change_source'].append(cs_bicycle_python)
|
|
|
|
c['change_source'].append(cs_bicycle_docker)
|
|
|
|
c['workers'].append(bicycle_worker)
|
|
|
|
c['builders'].append(bicycle_builder)
|
|
|
|
c['schedulers'].append(change_scheduler)
|
|
|
|
c['schedulers'].append(force_scheduler)
|
|
|
|
return c
|
2019-09-06 16:49:06 +02:00
|
|
|
|