I am trying to detect some environment variables that are derived from data in my repository:
machine: environment: METEOR_VERSION: $(cut -d@ -f2 app/.meteor/release) REVISION: $(git describe --tags) test: override: - echo $REVISION $METEOR_VERSION
the command substitution works but the environment is not ready as the variables are one of the first thing to be set up in the container. (I am aware of the git-describe caveats with shallow repositories and added
git fetch --tags in
checkout.post, but the environment is set up even before the git repo is fetched).
To solve this I suggest to enable the same functionality that runs
machine.environment to apply to
machine: environment: ONE: two checkout: post: - git fetch --tags test: environment: METEOR_VERSION: $(cut -d@ -f2 app/.meteor/release) REVISION: $(git describe --tags) override: - echo $REVISION $METEOR_VERSION
The environment keys would be set just for that block of commands (pre, override, post) and run before pre (but it wouldn’t be an issue if they exist for longer than that, as long as that is documented behaviour).
It is very unlikely that there are cases where the environment variable depends on a command that needs to be executed in the very same block as the command as the first one using the variable, and it can still be solved by inconveniently substituting the variable definition at the few references of the variable that cannot be fulfilled.