shell - 如何在buildbot的shell命令行中添加 "&&"?

标签 shell command-line buildbot

我需要使用“&&”一步执行多个命令。所以我创建工厂如下:

f1 = factory.BuildFactory()
f1.addStep(shell.ShellCommand, command=["sh", "-c", "pwd", "&&", "cd", "/home/xxx/yyy", "&&", "pwd"])

但是在执行过程中发现buildbot是这样处理的,导致无法执行
sh -c pwd '&&' cd /home/xxx/yyy '&&' pwd

我期望的是
sh -c pwd && cd /home/xxx/yyy && pwd

有人可以帮我解决这个问题吗?谢谢。

最佳答案

由于您使用的是 /bin/sh无论如何,只需用一个字符串调用它:

f1.addStep(shell.ShellCommand, command="pwd && cd /home/xxx/yyy && pwd")

正如文档所说:

The ShellCommand arguments are:

command

a list of strings (preferred) or single string (discouraged) which specifies the command to be run. A list of strings is preferred because it can be used directly as an argv array. Using a single string (with embedded spaces) requires the buildslave to pass the string to /bin/sh for interpretation, which raises all sorts of difficult questions about how to escape or interpret shell metacharacters.



不建议这样做,但无论如何您仍然需要 shell,如 &&仅在 shell 内解释。调用 sh只会是多余的。

关于shell - 如何在buildbot的shell命令行中添加 "&&"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25308364/

相关文章:

linux - 将特定编号的 Bash 文件描述符流式传输到变量中

windows - 如何使用 Perl 从 Windows 命令行获取文件的 SHA1 哈希值?

iphone - 如何从命令行在 iPhone 上启动 OCUnit 测试

python - Buildbot 不发送电子邮件?

linux - 找到一个文件并打开它进行编辑。如何在 bash shell 中快速完成?

php - 如何在 chrooted PHP-FPM 中执行程序?

arrays - 空格在 UNIX 数组中被视为分隔符

java - 记录数据、在命令行中输入数据、限制整数长度

buildbot - 如何在 buildbot 中公开构建

用于测试开源项目的Windows云实例?