docs
docs copied to clipboard
Environmental variables exported in `command` don't propagate
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.
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.
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.
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.