docs icon indicating copy to clipboard operation
docs copied to clipboard

Environmental variables exported in `command` don't propagate

Open jdotjdot opened this issue 7 years ago • 3 comments

We're trying to write a plugin configurable by the user in the command phase of the job, having the user set environmental variables then to be used by the post-command plugin hook.

We have found that when environmental variables are set in the command phase by the user, even using export, the variables fail to propagate to the post-command of the plugin.

jdotjdot avatar Oct 04 '18 02:10 jdotjdot

Sorry for the slow reply @jdotjdot. It's possible that command and checkout might have slightly different semantics than the pre and post style hooks, but I think they should still work as you described. I'll have a go at reproducing this one.

lox avatar Dec 16 '18 23:12 lox

After some investigation, it's as I said above, the command and checkout hooks don't get wrapped in the magic that lets us capture exported environment. At a minimum we should document this wrinkle and perhaps in future see what impact it would have to supporting this.

lox avatar Feb 18 '19 14:02 lox

I did some investigation into this area for another issue last week and found that command hooks do get the before- and after-environment behaviour applied, but a step’s command does not.

This is further complicated by whether the command hook early exits or not. Environment changes are missed under early exit, but captured and applied under natural termination.

keithduncan avatar Oct 05 '21 03:10 keithduncan