I need to use "&&" to execute multiple commands in one step. So I create factory as below:
f1 = factory.BuildFactory()
f1.addStep(shell.ShellCommand, command=["sh", "-c", "pwd", "&&", "cd", "/home/xxx/yyy", "&&", "pwd"])
But during execution it's found that buildbot processes it as below, which makes it impossible to execute
sh -c pwd '&&' cd /home/xxx/yyy '&&' pwd
What I expected is
sh -c pwd && cd /home/xxx/yyy && pwd
Could anyone help me out of this please? Thanks.
Since you're using /bin/sh
anyway just call it with a single string:
f1.addStep(shell.ShellCommand, command="pwd && cd /home/xxx/yyy && pwd")
As documentation says:
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.
It's not recommended but you'd still need the shell anyway as &&
is only interpreted within the shell. Calling sh
would just be redundant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With