5

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.

Benoit Blanchon
  • 13,364
  • 4
  • 73
  • 81

4 Answers4

4
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))
Virgil Gheorghiu
  • 493
  • 1
  • 4
  • 13
2

The better thing to do is to set a property in a previous step and then check the property in your doStepif method. the os.path.isfile you have there gets run at configure time, (buildbot startup) not run time.

David Dean
  • 2,682
  • 23
  • 34
0

I ended up solving this by letting the step run unconditionally but setting haltOnFailure=False. This way if the required file doesn't exist it fails but doesn't kill the rest of the build.

dshepherd
  • 4,989
  • 4
  • 39
  • 46
-5

Just use simple python if statement before the step:

if(condition):
  your buildbot step
277roshan
  • 354
  • 1
  • 3
  • 13
  • 2
    This is not how buildbot works. Steps cannot be added conditionally like this, because on 'Run' of the master script, that directory may not exist. The step itself has to have the logic to skip through doStepIf. The [documentation](http://docs.buildbot.net/latest/manual/cfg-properties.html?highlight=conditional#using-properties-in-steps) even mentions that having conditionals doesn't work as expected. – KymikoLoco Nov 02 '15 at 16:39