bhearsum%mozilla.com 49ffa552f7 bug 422103: master-side command to set mozilla-related build properties. r=rhelmer, patch=me
git-svn-id: svn://10.0.0.236/trunk@248537 18797224-902f-48f8-a5cc-f745e15eee43
2008-03-25 13:08:33 +00:00

91 lines
3.6 KiB
Python

import buildbot
from buildbot.process.buildstep import LoggedRemoteCommand, LoggingBuildStep
from buildbot.steps.shell import ShellCommand
from buildbot.status.builder import FAILURE, SUCCESS
class GetBuildID(ShellCommand):
"""Retrieves the BuildID from a Mozilla tree (using platform.ini) and sets
it as a build property ('buildid'). If defined, uses objdir as it's base.
"""
description=['getting buildid']
descriptionDone=['get buildid']
haltOnFailure=True
def __init__(self, objdir="", **kwargs):
ShellCommand.__init__(self, **kwargs)
major, minor, point = buildbot.version.split(".", 3)
# Buildbot 0.7.5 and below do not require this
if int(minor) >= 7 and int(point) >= 6:
self.addFactoryArguments(objdir=objdir)
self.objdir = objdir
self.command = ['python', 'config/printconfigsetting.py',
'%s/dist/bin/application.ini' % self.objdir,
'App', 'BuildID']
def commandComplete(self, cmd):
buildid = ""
try:
buildid = cmd.logs['stdio'].getText().strip().rstrip()
self.setProperty('buildid', buildid)
except:
log.msg("Could not find BuildID or BuildID invalid")
log.msg("Found: %s" % buildid)
return FAILURE
return SUCCESS
class SetMozillaBuildProperties(LoggingBuildStep):
"""Gathers and sets build properties for the following data:
buildid - BuildID of the build (from application.ini, falling back on
platform.ini)
appVersion - The version of the application (from application.ini, falling
back on platform.ini)
packageFilename - The filename of the application package
packageSize - The size (in bytes) of the application package
packageHash - The sha1 hash of the application package
installerFilename - The filename of the installer (win32 only)
installerSize - The size (in bytes) of the installer (win32 only)
installerHash - The sha1 hash of the installer (win32 only)
completeMarFilename - The filename of the complete update
completeMarSize - The size (in bytes) of the complete update
completeMarHash - The sha1 hash of the complete update
All of these will be set as build properties -- even if no data is found
for them. When no data is found, the value of the property will be None.
This function requires an argument of 'objdir', which is the path to the
objdir relative to the builddir. ie, 'mozilla/fx-objdir'.
"""
def __init__(self, objdir="", **kwargs):
LoggingBuildStep.__init__(self, **kwargs)
self.addFactoryArguments(objdir=objdir)
self.objdir = objdir
def describe(self, done=False):
if done:
return ["gather", "build", "properties"]
else:
return ["gathering", "build", "properties"]
def start(self):
args = {'objdir': self.objdir, 'timeout': 60}
cmd = LoggedRemoteCommand("setMozillaBuildProperties", args)
self.startCommand(cmd)
def evaluateCommand(self, cmd):
# set all of the data as build properties
# some of this may come in with the value 'UNKNOWN' - these will still
# be set as build properties but 'UNKNOWN' will be substituted with None
try:
log = cmd.logs['stdio'].getText()
for property in log.split("\n"):
name, value = property.split(": ")
if value == "UNKNOWN":
value = None
self.setProperty(name, value)
except:
return FAILURE
return SUCCESS