Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buildbot: how to skip a step if a file doesn't exist?

Tags:

buildbot

I need to skip a build step when building some branches.

More exactly, I want to execute a ShellCommand step only if the script to be ran is present on the source tree.

I tried:

ShellCommand(command=["myscript"],
             workdir="path/to",
             doStepIf=(lambda step: os.path.isfile("path/to/myscript")))

but the step is never executed.

like image 428
Benoit Blanchon Avatar asked Oct 31 '22 09:10

Benoit Blanchon


1 Answers

def doesMyCriticalFileExist(step):
   if step.getProperty("myCriticalFileExists"):
      return True
   return False

<factory>.addStep(SetProperty(command='[ -f /path/to/myscript ] && ls -1 /path/to/myscript || exit 0', property='myCriticalFileExists')))
<factory>.addStep(ShellCommand(command=["myscript"], workdir="path/to", doStepIf=doesMyCriticalFileExist))
like image 133
Virgil Gheorghiu Avatar answered Dec 20 '22 00:12

Virgil Gheorghiu