Ticket #100 (assigned enhancement)

Opened 1 year ago

Last modified 3 months ago

Builder should be able to take a 'env' argument that applies to all BuildSteps

Reported by: bhearsum Assigned to: bhearsum (accepted)
Priority: minor Milestone: 0.8.0
Component: other Version:
Keywords: Cc: dustin, dwlocks

Description

I think it's a fairly common use case that all of a Builder's BuildSteps? require the same environment variables. I propose that the Builder 'setup' should be able to take in a dict of environment variables and pass it along to all BuildSteps? that require/support it (ie. it wouldn't pass it to something like FileDownload?).

I'd be happy to code this up myself assuming it is wanted.

Attachments

builderWideEnvironnment.diff (1.5 kB) - added by bhearsum on 04/30/08 12:25:27.
builder-wide environment
builderWideEnvironnment-v2.diff (1.5 kB) - added by bhearsum on 04/30/08 13:29:54.
same as before, fix stupid error (setup.get(env?) -> setup.get('env'))
builderWideEnvironnment-with-tests.diff (6.6 kB) - added by bhearsum on 05/26/08 09:26:45.
again, with tests + clarified ShellCommand?.setupEnviornment
builderEnv-docs.diff (1.1 kB) - added by bhearsum on 05/29/08 08:18:56.
docs

Change History

04/28/08 14:48:12 changed by warner

yeah, that sounds reasonable. I frequently do this by setting up the environment of the buildslave, but I can see where you'd want to do it per-Builder instead. Let's make env= an argument to the Builder __init__ that we should build for ticket #10 .

04/28/08 15:43:18 changed by bhearsum

Sounds good.

04/28/08 17:09:38 changed by dustin

  • cc set to dustin, dwlocks.

+1

04/30/08 12:25:27 changed by bhearsum

  • attachment builderWideEnvironnment.diff added.

builder-wide environment

04/30/08 12:26:56 changed by bhearsum

This first patch is as-of-yet untested but I'm pretty sure it'll work. ShellCommands? automatically pull in the Build.slaveEnvironment dictionary.

I'll do some testing today/tomorrow and see how it goes.

04/30/08 12:27:00 changed by bhearsum

  • status changed from new to assigned.

04/30/08 13:29:54 changed by bhearsum

  • attachment builderWideEnvironnment-v2.diff added.

same as before, fix stupid error (setup.get(env?) -> setup.get('env'))

04/30/08 13:31:10 changed by bhearsum

  • milestone changed from undecided to 0.7.8.

I tested this one and it works as intended and passes unit tests.

05/15/08 15:54:47 changed by dustin

Looks good .. needs tests, though, and it would be *great* to get rid of:

    def setupEnvironment(self, cmd):
        # XXX is this used? documented? replaced by properties?
        # merge in anything from Build.slaveEnvironment . Earlier steps
        # (perhaps ones which compile libraries or sub-projects that need to
        # be referenced by later steps) can add keys to
        # self.build.slaveEnvironment to affect later steps.

05/15/08 18:20:49 changed by bhearsum

You're absolutely right about the tests.

Let me do some thinking and tinkering about setupEnvironment() before I comment on that.

05/15/08 18:30:47 changed by bhearsum

OK, I'm not clear on what you want to get rid of? The function, or the 'XXX' comment..?

05/15/08 19:23:45 changed by dustin

I'd like to resolve the concerns in the comment -- the function can stay, if it's still in use.

It's part of my "leave it cleaner than when you came" patch policy :)

05/22/08 11:54:34 changed by bhearsum

Okay, it seems clear that my patch depends on ShellCommand?.setupEnvironment(). After looking at it closer I realized that in its current form, the builder-wide environment will override anything in the BuildStep? environment. I would consider this incorrect. However, if a BuildStep? were to set something in slaveEnvironment it would make sense for it to override the BuildStep? environment (IMHO). Therefore, I propose that a BuildStep? setting something in slaveEnvironment be superceded by BuildProperties?, as suggested by the documentation. I'm pretty sure you can use WithProperties? with env vars, so I don't see any reason to support that operation.

If that makes sense, I can make the following changes to my patch: * Add tests * Make the BuildStep?-environment override the Builder environment * Add documentation that describes the Builder environment, and makes clear exactly how BuildStep? environment setting works.

05/22/08 11:58:07 changed by dustin

sounds good!

05/26/08 09:26:45 changed by bhearsum

  • attachment builderWideEnvironnment-with-tests.diff added.

again, with tests + clarified ShellCommand?.setupEnviornment

05/27/08 06:33:12 changed by bhearsum

Oops, I forgot to write docs for this. I'll add them shortly.

05/29/08 08:18:56 changed by bhearsum

  • attachment builderEnv-docs.diff added.

docs

07/16/08 07:31:25 changed by bhearsum

Is this going to get landed for 0.7.8?

07/16/08 10:32:43 changed by warner

some thoughts:

  • I suspect somebody will eventually complain that WithProperties aren't accepted in the builder-wide settings like they are in the per-step settings.. you might want to merge in the builder-wide dict first, *then* do the properties.render() call
  • if you do that, the docs should be updated to mention this feature
  • the docs should probably have an example of what you might want to use this for. They should also mention the possibility of setting environment variables in the buildslave's startup environment, since variables like that are sometimes slave-specific

Otherwise, it looks good to me.

08/20/08 06:37:23 changed by dustin

bhearsum, what do you think of warner's suggestions? We can break those out into separate tickets, or fix them here.