[Buildbot-devel] dynamically finding the workdir for some build step
Philippe McLean
philippe.mclean at gmail.com
Tue May 3 00:42:21 UTC 2011
This is what I use (for a windows slave). Maybe over-engineered but it works
setting the property:
factory.addStep(SetProperty(command=["python", "-c", "import os, sys;
print os.getcwd(); sys.exit(0)"], property='absBuildDir'))
using the property:
factory.addStep(ShellCommand(description="change source folder",
command=["change_source_folder.bat", WithProperties("%(absBuildDir)s"),
config, "CONFIG"], workdir="build\\Scripts",
name="change_source_folder.bat"));
On Fri, Apr 29, 2011 at 9:10 PM, Matthew Morse <matt at apple.com> wrote:
> Amber,
>
> WithProperties was exactly what I needed. Took me some time to figure out
> how to use it, but it boiled down to:
>
> desired_path = "desired_path" # property name
> def set_lagos_bookshelf_path(rc, stdout, stderr):
> sc_path = stdout.strip()
> return { desired_path : sc_path }
>
> builder.addStep(
> shell.SetProperty,
> command="<some_command_that_returns_the_path>",
> workdir="some_path",
> extract_fn=set_lagos_bookshelf_path,
> )
>
> builder.addStep(
> shell.ShellCommand,
> command="<some_command>",
> workdir=WithProperties("%s", desired_path),
> )
>
> Also your SetProperty step needs a property name specified.
>
> I think that with the extract_fn form, I'm not supposed to set the property
> name:
>
> The more advanced usage allows you to specify a function to extract
> properties from the command output. Here you can use regular expressions,
> string interpolation, or whatever you would like. In this form,extract_fn should
> be passed, and not property. The extract_fn function is called with three
> arguments: the exit status of the command, its standard output as a string,
> and its standard error as a string. It should return a dictionary containing
> all new properties.
> (http://buildbot.net/buildbot/docs/latest/full.html#SetProperty)
>
> Thanks for your help,
> - Matt
>
> On Apr 29, 2011, at 7:18 PM PDT, Amber Yust wrote:
>
> WithProperties. Also your SetProperty step needs a property name specified.
>
> ~Amber (sent from Droid, please forgive any typos!)
> On Apr 29, 2011 7:09 PM, "Matthew Morse" <matt at apple.com> wrote:
> > Hi,
> >
> > I haven't been having luck figuring this out, and it seems like it should
> be easy (so I'm frustrated ;-).
> >
> > The problem is that I don't know the workdir for some step until runtime
> (the folder name has a git hash in it that changes).
> >
> > But, I have a command that will find the proper path for me. So, I want
> to run that command, get the path, and use it for the next build step. It
> looks like a SetProperty step is what I want, but how do I pass the property
> between buildsteps?
> >
> >
> > Here's the situation in code:
> >
> >
> --------------------------------------------------------------------------------
> > def new_working_dir_path(rc, stdout, stderr):
> > desired_path = stdout.strip()
> > return { "desired_path" : desired_path }
> >
> >
> > # Get path for following step
> > builder.addStep(
> > shell.SetProperty,
> > command=some_command_that_prints_desired_path_to_stdout,
> > extract_fn=new_working_dir_path,
> > )
> >
> >
> > builder.addStep(
> > shell.ShellCommand,
> > command=some_command_that_needs_to_execute_at_the_desired_path,
> > workdir=<how do I get to the desired_path property?>,
> > )
> >
> --------------------------------------------------------------------------------
> >
> >
> > Thanks,
> > - Matt
> >
> >
> >
> ------------------------------------------------------------------------------
> > WhatsUp Gold - Download Free Network Management Software
> > The most intuitive, comprehensive, and cost-effective network
> > management toolset available today. Delivers lowest initial
> > acquisition cost and overall TCO of any competing solution.
> > http://p.sf.net/sfu/whatsupgold-sd
> > _______________________________________________
> > Buildbot-devel mailing list
> > Buildbot-devel at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/buildbot-devel
>
>
>
>
> ------------------------------------------------------------------------------
> WhatsUp Gold - Download Free Network Management Software
> The most intuitive, comprehensive, and cost-effective network
> management toolset available today. Delivers lowest initial
> acquisition cost and overall TCO of any competing solution.
> http://p.sf.net/sfu/whatsupgold-sd
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20110502/23196c02/attachment.html>
More information about the devel
mailing list