返回介绍

2.5.12.20. Shell Sequence

发布于 2023-09-20 23:50:39 字数 5870 浏览 0 评论 0 收藏 0

Caution

Buildbot no longer supports Python 2.7 on the Buildbot master.

2.5.12.20. Shell Sequence

Some steps have a specific purpose, but require multiple shell commands to implement them. For example, a build is often configure; make; make install. We have two ways to handle that:

  • Create one shell command with all these. To put the logs of each commands in separate logfiles, we need to re-write the script as configure 1> configure_log; ... and to add these configure_log files as logfiles argument of the buildstep. This has the drawback of complicating the shell script, and making it harder to maintain as the logfile name is put in different places.

  • Create three ShellCommand instances, but this loads the build UI unnecessarily.

ShellSequence is a class that executes not one but a sequence of shell commands during a build. It takes as argument a renderable, or list of commands which are ShellArg objects. Each such object represents a shell invocation.

The single ShellSequence argument aside from the common parameters is:

commands

A list of ShellArg objects or a renderable that returns a list of ShellArg objects.

from buildbot.plugins import steps, util

f.addStep(steps.ShellSequence(
    commands=[
        util.ShellArg(command=['configure']),
        util.ShellArg(command=['make'], logname='make'),
        util.ShellArg(command=['make', 'check_warning'], logname='warning',
                      warnOnFailure=True),
        util.ShellArg(command=['make', 'install'], logname='make install')
    ]))

All these commands share the same configuration of environment, workdir and pty usage that can be set up the same way as in ShellCommand.

class buildbot.steps.shellsequence.ShellArg(self, command=None, logname=None, haltOnFailure=False, flunkOnWarnings=False, flunkOnFailure=False, warnOnWarnings=False, warnOnFailure=False)
Parameters:
  • command – (see the ShellCommand command argument),

  • logname – optional log name, used as the stdio log of the command

The haltOnFailure, flunkOnWarnings, flunkOnFailure, warnOnWarnings, warnOnFailure parameters drive the execution of the sequence, the same way steps are scheduled in the build. They have the same default values as for buildsteps - see Parameters Common to all Steps.

Any of the arguments to this class can be renderable.

Note that if logname name does not start with the prefix stdio, that prefix will be set like stdio <logname>. If no logname is supplied, the output of the command will not be collected.

The two ShellSequence methods below tune the behavior of how the list of shell commands are executed, and can be overridden in subclasses.

class buildbot.steps.shellsequence.ShellSequence
shouldRunTheCommand(oneCmd)
Parameters:

oneCmd – a string or a list of strings, as rendered from a ShellArg instance’s command argument.

Determine whether the command oneCmd should be executed. If shouldRunTheCommand returns False, the result of the command will be recorded as SKIPPED. The default method skips all empty strings and empty lists.

getFinalState()

Return the status text of the step in the end. The default value is to set the text describing the execution of the last shell command.

runShellSequence(commands):
Parameters:

commands – list of shell args

This method actually runs the shell sequence. The default run method calls runShellSequence, but subclasses can override run to perform other operations, if desired.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文