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

env variables in exec commands are not properly exported #4232

Closed
kadel opened this issue Nov 17, 2020 · 2 comments · Fixed by #4267
Closed

env variables in exec commands are not properly exported #4232

kadel opened this issue Nov 17, 2020 · 2 comments · Fixed by #4267
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)).
Projects

Comments

@kadel
Copy link
Member

kadel commented Nov 17, 2020

/kind bug

What versions of software are you using?

Operating System:

Output of odo version:

How did you run odo exactly?

I have a devfile that defines a command spawning new shell, for example like this:

  - id: build 
    exec:
      component: tools
      commandLine: "sh -c 'echo foo is $foo'"
      group:
        kind: build
        isDefault: true
      env:
        - name: foo
          value: bar

Actual behavior

▶ odo push --show-log

Validation
 ✓  Validating the devfile [56469ns]

Creating Kubernetes resources for component java-maven
 ✓  Waiting for component to start [26s]

Applying URL changes
 ✓  URLs are synced with the cluster, no changes are required.

Syncing to component java-maven
 ✓  Checking file changes for pushing [1ms]
 ✓  Syncing files to the component [2s]

Executing devfile commands for component java-maven
 •  Executing build command "sh -c 'echo foo is $foo'"  ...
foo is

Expected behavior


Validation
 ✓  Validating the devfile [56469ns]

Creating Kubernetes resources for component java-maven
 ✓  Waiting for component to start [26s]

Applying URL changes
 ✓  URLs are synced with the cluster, no changes are required.

Syncing to component java-maven
 ✓  Checking file changes for pushing [1ms]
 ✓  Syncing files to the component [2s]

Executing devfile commands for component java-maven
 •  Executing build command "sh -c 'echo foo is $foo'"  ...
foo is bar

notice the last line, it should print the correct value of $foo value

more info

When command defines the env variable than odo executes it as <env.name>=<env.value> && <commandLine>.
But the correct behavior should be export <env.name>=<env.value> && <commandLine>. Export is important as it will make sure that the variable is available in all subshells not just in the current shell.

This is not just for build command, but for run and any other commands that have this behavior.

/priority high
/kind bug

@openshift-ci-robot openshift-ci-robot added kind/bug Categorizes issue or PR as related to a bug. priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)). labels Nov 17, 2020
@kadel kadel added this to For Consideration in Sprint 193 via automation Nov 17, 2020
@mik-dass mik-dass self-assigned this Nov 18, 2020
@dharmit
Copy link
Member

dharmit commented Dec 4, 2020

@mik-dass can you move this on the board please?

@mik-dass mik-dass moved this from For Consideration to To do in Sprint 193 Dec 4, 2020
@mik-dass mik-dass moved this from To do to In progress in Sprint 193 Dec 4, 2020
@mik-dass mik-dass moved this from In progress to For Review in Sprint 193 Dec 4, 2020
@mik-dass
Copy link
Contributor

mik-dass commented Dec 4, 2020

@mik-dass can you move this on the board please?

Done.

Sprint 193 automation moved this from For Review to Done Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)).
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants