2016-03-04 31 views
1

我想保存每晚構建的副本,我想將每個構建放入其自己的日常文件夾中將是想法。但是我不能使用時間從buildbot Master.cfg中,因爲當它被配置來設置它:如何使用buildbot創建每日生成文件夾?

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

我將如何獲得在目的地使用的當前運行日期?

回答

0

您需要在構建配置的運行時將日期設置爲屬性。做這樣的事情:

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

確保導入插和setPropertyFromCommand問:

from buildbot.process.properties import Interpolate 
from buildbot.steps.shell import SetPropertyFromCommand 
相關問題