【问题标题】:How to a create a daily build folder using buildbot?如何使用 buildbot 创建每日构建文件夹?
【发布时间】:2016-03-04 10:30:56
【问题描述】:

我想保存夜间构建的副本,我认为将每个构建放入自己的日常文件夹中是个好主意。但是我不能使用 buildbot master.cfg 中的时间,因为它是在配置时设置的:

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"]))

如何获取当前运行日期以在目的地使用?

【问题讨论】:

    标签: buildbot


    【解决方案1】:

    您需要在运行时在构建配置中将日期设置为属性。做这样的事情:

    my_return.addStep(SetPropertyFromCommand(
        property = 'dateRightNow', 
        command = ['python', '-c', '"import datetime;print  datetime.datetime.now().strftime('%y-%m-%d')"']
        ))
    

    对于 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(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
    

    【讨论】:

      【解决方案2】:

      更好的方法是为util.Interpolate(...)使用自定义渲染器

      @util.renderer
      def cur_date(props):
          return datetime.date.today().isoformat()
      

      稍后在构建工厂步骤中将其用作自定义关键字

      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)))
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-28
        • 2013-12-29
        • 1970-01-01
        • 1970-01-01
        • 2021-05-16
        相关资源
        最近更新 更多