擅长:python、mysql、java
<p>另一个选择是在虚拟环境中直接调用python可执行文件,因为许多提供命令行命令的python工具通常都可以作为模块执行:</p>
<pre><code>from buildbot.steps.shell import ShellCommand
factory = util.BuildFactory()
# STEPS for example-slave:
factory.addStep(ShellCommand(command=['virtualenv', 'venvCI']))
factory.addStep(ShellCommand(
command=['./venvCI/bin/python', '-m', 'pip', 'install', '-r', 'development.pip']))
factory.addStep(ShellCommand(
command=['./venvCI/bin/python', '-m', 'pyflakes', 'calculator.py']))
factory.addStep(ShellCommand(command=['python', 'test.py']))
</code></pre>
<p>然而,过了一段时间,这确实会让人厌烦。您可以使用<code>string.Template</code>生成辅助对象:</p>
^{pr2}$
<p>然后你可以这样做:</p>
<pre><code>addstep('$python -m pip install pytest', python='./venvCI/bin/python')
</code></pre>
<p>这些是一些开始的想法。请注意,<code>shlex</code>的一个妙处是,在进行拆分时,它将考虑带引号的字符串内的空格。在</p>