如何使用buildbot创建每日生成文件夹?
我想保存一份夜间构建的副本,我想把每个构建放在自己的每日文件夹中是个好主意。但是,我无法使用buildbot master.cfg中的时间,因为它是在配置时设置的:如何使用buildbot创建每日生成文件夹?,buildbot,Buildbot,我想保存一份夜间构建的副本,我想把每个构建放在自己的每日文件夹中是个好主意。但是,我无法使用buildbot master.cfg中的时间,因为它是在配置时设置的: copy_files = [".\\release\\MyProgram.exe", ".\\install\\ChangeLog.js", ".\\translations.txt"] server_dest_path_by_date = server_dest_path +
copy_files = [".\\release\\MyProgram.exe",
".\\install\\ChangeLog.js",
".\\translations.txt"]
server_dest_path_by_date = server_dest_path + "\\{0}".format(time.strftime("%Y-%m-%d"))
my_return.addStep(steps.MakeDirectory(dir=server_dest_path_by_date))
for file in copy_files:
my_return.addStep(ShellCommand(command=["copy", file, server_dest_path_by_date, "/y"]))
如何获取目标中使用的当前运行日期?您需要在生成配置的运行期间将该日期设置为属性。这样做:
my_return.addStep(SetPropertyFromCommand(
property = 'dateRightNow',
command = ['python', '-c', '"import datetime;print datetime.datetime.now().strftime('%y-%m-%d')"']
))
my_return.addStep(steps.MakeDirectory(
dir=Interpolate('%(prop:dateRightNow)s')))
for file in copy_files:
my_return.addStep(ShellCommand(command=["copy", file, Interpolate('%(prop:dateRightNow)s'), "/y"]))
对于Python 3.6:
my_return.addStep(SetPropertyFromCommand(
property = 'dateRightNow',
command = ['python', '-c', 'import datetime;print(datetime.datetime.now().strftime("%y-%m-%d"))']
))
然后使用如下属性:
my_return.addStep(SetPropertyFromCommand(
property = 'dateRightNow',
command = ['python', '-c', '"import datetime;print datetime.datetime.now().strftime('%y-%m-%d')"']
))
my_return.addStep(steps.MakeDirectory(
dir=Interpolate('%(prop:dateRightNow)s')))
for file in copy_files:
my_return.addStep(ShellCommand(command=["copy", file, Interpolate('%(prop:dateRightNow)s'), "/y"]))
确保将Interpolate和setPropertyFromCommand导入到:
from buildbot.process.properties import Interpolate
from buildbot.steps.shell import SetPropertyFromCommand
更好的方法是为
util.Interpolate(…)
然后在构建工厂步骤中将其用作自定义关键字
cppcheck_dst = '/home/upload/%(kw:cur_date)s/'
bF.addStep(steps.MakeDirectory(dir=util.Interpolate(cppcheck_dst, cur_date=cur_date)))
bF.addStep(steps.CopyDirectory(src='build/build.scan/static/',
dest=util.Interpolate(cppcheck_dst, cur_date=cur_date)))