Skip to content

Instantly share code, notes, and snippets.

@sric0880
Last active July 23, 2017 08:34
Show Gist options
  • Save sric0880/230571ef5ecb4883fe08a927adcf20aa to your computer and use it in GitHub Desktop.
Save sric0880/230571ef5ecb4883fe08a927adcf20aa to your computer and use it in GitHub Desktop.
change branch master to dev, master is used for github
# -*- python -*-
# ex: set filetype=python:
from buildbot.plugins import *
import subprocess
import re
import os
# This is a sample buildmaster config file. It must be installed as
# 'master.cfg' in your buildmaster's base directory.
# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}
####### WORKERS
# The 'workers' list defines the set of recognized workers. Each element is
# a Worker object, specifying a unique worker name and password. The same
# worker name and password must be configured on the worker.
c['workers'] = [worker.Worker("unitybuild-worker", "password")]
# 'protocols' contains information about protocols which master will use for
# communicating with workers. You must define at least 'port' option that workers
# could connect to your master with this protocol.
# 'port' must match the value configured into the workers (with their
# --master option)
c['protocols'] = {'pb': {'port': 9989}}
####### CHANGESOURCES
git_repo = 'http://sric0880@127.0.0.1/sric0880/unity-framework.git'
svn_repo = 'svn://localhost/resources'
# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes.
c['change_source'] = []
c['change_source'].append(changes.GitPoller(
git_repo,
workdir='gitpoller-workdir',
branches=True,
project = 'unity-framework',
pollinterval=300))
c['change_source'].append(changes.SVNPoller(
repourl=svn_repo,
split_file=util.svn.split_file_branches,
project = 'resources'
))
####### SCHEDULERS
def Branches():
branches = []
refs = subprocess.check_output(["git", "ls-remote", "--heads", git_repo])
for item in refs.split('\n'):
m = re.match(r"^\w+\trefs/heads/(.*)$", item)
if m and m.group(1):
branch = m.group(1)
branches.append(branch)
return branches
def RevisionsOfSvn():
revs = []
revs_str = subprocess.check_output(["svn", "log", "-l 20", svn_repo])
for item in revs_str.split('\n'):
if len(item) == 0 or item[0] == '-':
continue
if item[0] == 'r':
line = item[0:item.find('+')]
revs.append(line)
return revs
svn_revisions = RevisionsOfSvn()
git_branches = Branches()
all_channels = [
"android-yyb",
"mac-nosdk",
"ios-nosdk",
"windows-test"
]
c['schedulers'] = []
c['schedulers'].append(schedulers.ForceScheduler(
name="force",
buttonName="Build",
builderNames=["unitybuild"],
codebases=[
util.CodebaseParameter(
"",
name="Git repository",
branch=util.ChoiceStringParameter(
name="branch",
strict=True,
choices=git_branches,
default=git_branches[0]),
# not support remote list git revisions
revision=util.FixedParameter(name="revision", default=""),
repository=util.FixedParameter(name="repository", default=""),
project = 'unity-framework'
)],
properties=[
util.NestedParameter(name="", label="Build Options", layout="vertical", columns = 3,
fields=[
util.ChoiceStringParameter(
name="channels",
multiple=True,
strict=True,
choices=all_channels,
default=all_channels[0],),
util.StringParameter(name="version-name", default="1.0.0", size=20),
util.ChoiceStringParameter(
name="svn-rev",
choices=svn_revisions,
default=svn_revisions[0]),
])
]
))
####### BUILDERS
# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
# what steps, and which workers can execute them. Note that any particular build will
# only take place on one worker.
factory = util.BuildFactory()
# check out the source
factory.addStep(steps.Git(repourl=git_repo, branch=util.Interpolate('%(src::branch)s'),
workdir='unity-framework',
logEnviron=False,
mode='full',
method='clean',
submodules=True))
factory.addStep(steps.SVN(repourl=util.Interpolate(svn_repo+'/branches/%(src::branch)s'),
workdir='resources',
logEnviron=False,
mode='full',
method='fresh'))
@util.renderer
def makeCommand(props):
command = ['unitybuild']
channels = props.getProperty('channels')
if channels:
channelsParameter = ','.join(channels)
command.extend(['-c', channelsParameter])
command.extend(['--version-name', util.Interpolate('%(prop:version-name)s')])
command.extend(['--version-code', util.Interpolate('%(prop:buildnumber)s')])
command.extend(['--unity-project', util.Interpolate('%(prop:builddir)s/unity-framework')])
command.extend(['-b', util.Interpolate('%(src::branch)s')])
command.extend(['--output', './output'])
svnrev = props.getProperty('svn-rev')
if svnrev:
m = re.match(r"^r(\d+)\s|", svnrev)
if m and m.group(1):
revStr = m.group(1)
command.extend(['--svn-rev', revStr])
return command
factory.addStep(steps.ShellCommand(command=makeCommand, workdir=''))
c['builders'] = []
c['builders'].append(
util.BuilderConfig(name="unitybuild",
workernames=["unitybuild-worker"],
factory=factory))
####### BUILDBOT SERVICES
# 'services' is a list of BuildbotService items like reporter targets. The
# status of each build will be pushed to these targets. buildbot/reporters/*.py
# has a variety to choose from, like IRC bots.
c['services'] = []
####### PROJECT IDENTITY
# the 'title' string will appear at the top of this buildbot installation's
# home pages (linked to the 'titleURL').
c['title'] = "Unitybuild"
c['titleURL'] = ""
# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server is visible. This typically uses the port number set in
# the 'www' entry below, but with an externally-visible host name which the
# buildbot cannot figure out without some help.
c['buildbotURL'] = "http://127.0.0.1:8010/"
# minimalistic config to activate new web UI
c['www'] = {
'port' : 8010,
'plugins' : {}
}
####### DB URL
c['db'] = {
# This specifies what database buildbot uses to store its state. You can leave
# this at its default for all but the largest installations.
'db_url' : "sqlite:///state.sqlite",
}
@sric0880
Copy link
Author

buildbot config file customized for unity-buildscripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment