MisterJ
MisterJ

Reputation: 929

Buildbot master.cfg conditional depending on property

I face a weird problem with extremly slow file upload on my windows slave buildbot. For example a file upload of a 60Mb files takes almost 2 minutes whereas the same zip on the same network is only taking a few seconds.

To work around this, I thought about using a good old scp to upload my files under Windows, but I didn't succeed there since I am not able to do a conditional choice of what function to use to upload the file given a property I previously set.

I am trying to do so like this

if(Interpolate("%(prop:osName)s")=='windows'):
    uploadWindows(args)
else:
    upload_file(args)

But I have no success doing that even if the osName property is correctly set.

Upvotes: 2

Views: 2407

Answers (2)

Poko
Poko

Reputation: 822

Personnaly I use doStepIf for my conditionnals steps. You just need to add the argument doStepIf=yourfunctionName

def yourfunctionName(step):
    if step.getProperty("buildslave") == "windows":
       return True
    return false

f.addStep(ShellCommand(command=WithProperties("scp"),
                      description=[""],
                      descriptionDone=["do my scp"],
                      doStepIf=yourfunctionName))

In your case you will need 2 steps for the same action.

You should take a look here: http://docs.buildbot.net/latest/manual/cfg-buildsteps.html#buildstep-common-parameters

Hope it could help

Upvotes: 7

Topher
Topher

Reputation: 596

You need to make sure that the Property has been set in the time that you're trying to access it.

I'm not sure if that's your issue or not, but I was unable to get Interpolate to work at all. I ended up using a renderer function to make sure I could access the Property data.

Check the docs and example here: http://docs.buildbot.net/latest/manual/cfg-properties.html#renderer (note the "props" variable, which gives access to a Property)

Upvotes: 1

Related Questions