简体   繁体   English

如何从Buildbot捕获内部版本号

[英]How to capture the build number from the Buildbot

Is there a variable that I can access in master.cfg ? master.cfg可以访问一个变量吗? The docs aren't clear at all. 这些文档还不清楚。 Thanks. 谢谢。

There are ways of getting this information, but it depends on where you are trying to access it. 有多种获取信息的方法,但这取决于您尝试访问它的位置。

If you are inside a doStepIf procedure (as a parameter to addStep ), this should work: 如果您位于doStepIf过程(作为addStep的参数)中,则此方法应该起作用:

def insideDoStepIf(step):
    step.build.getStatus().number

If you are trying to prioritize your builders by their next build number, this should work: 如果您尝试按其下一个内部版本号对您的构建器进行优先级排序,则此方法应该起作用:

def buildPriority(buildmaster, builders):
    builders.sort(key=lambda b: b.builder_status.nextBuildNumber)
    return builders

c['prioritizeBuilders'] = buildPriority

If you are interested in getting this information in a messageFormatter function for a buildbot.status.mail.MailNotifier , try this: 如果您有兴趣在buildbot.status.mail.MailNotifiermessageFormatter函数中获取此信息,请尝试以下操作:

def formatEmail(mode, name, build, results, master_status):
    for builder in master_status.getBuilderNames():
        master_status.getBuilder(builder).nextBuildNumber

I did not test these, and I can't guarantee that the api here is stable, but I'm pretty confident that these should work, as I'm doing a few similar things (though, not with build number) in my own master.cfg 我没有测试这些,并且不能保证这里的api是稳定的,但是我非常有信心这些应该可以工作,因为我自己在做一些类似的事情(尽管没有内部版本号) master.cfg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM