Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump and unbump share environment variable object #3492

Closed
zsstiers opened this issue Mar 28, 2024 · 0 comments · Fixed by #3638
Closed

bump and unbump share environment variable object #3492

zsstiers opened this issue Mar 28, 2024 · 0 comments · Fixed by #3638
Labels
bug Something isn't working

Comments

@zsstiers
Copy link

zsstiers commented Mar 28, 2024

The bump and unbump tasks interfere with each other's environment variables. For example, if you do

project.tasks.tryFind("bump")?.env("EXAMPLE", "foo");

you will find that "EXAMPLE": "foo" appears in both the bump and unbump tasks in tasks.json.

This becomes problematic when wanting to set the same environment variable to different values. For example, if you desired to do

project.tasks.tryFind("bump")?.env("STEP_NAME", "bump");
project.tasks.tryFind("unbump")?.env("STEP_NAME", "unbump");

you'd find that "STEP_NAME" is "unbump" in both cases.

I'm not sure what the intended behavior of

const env = {};
project.addTask("example", {
  exec: 'echo "Hello world"',
  env,
});
env.EXAMPLE = "foo";

is though, so I'm not sure what the most appropriate fix is.

If the intended behavior is that EXAMPLE has been added to the task then I think the fix is to replace env: env with env: { ...env } in at least one of the locations in https://github.com/projen/projen/blob/main/src/version.ts#L105-L117.

If the intended behavior is that EXAMPLE is not added then I think the fix is for https://github.com/projen/projen/blob/main/src/task.ts#L63 to be this._env = { ...props.env };. This second approach would imply the need for similar changes to conditions, steps, and requiredEnv though.

@mrgrain mrgrain added the bug Something isn't working label Apr 4, 2024
mergify bot pushed a commit that referenced this issue Jun 7, 2024
…3638)

Fixes #3492

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
@mergify mergify bot closed this as completed in #3638 Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants