Skip to content

ExportAs has no effect in case the environment variable already exists #88

@aldobazzi

Description

@aldobazzi

Hello,

I am trying to set an environment variable with a specific name as task output and re-using the environment variable in subsequent task of a pipeline.
If an environment variable with the exact same name already exists in the environment, then the exportAs seems to have no effect, i.e. it has the external value. Is this expected behavior?

It can be reproduce with the following taskctl.yml file

tasks:
  set-var-value:
    command:
      - printf "var-value-changed"
    exportAs: VAR_NAME
  use-var-value:
    command:
      - printf "${VAR_NAME}"

pipelines:
  test-export-as-override:
    - task: set-var-value
    - task: use-var-value
      depends_on: get-var-value

If the pipeline is run in the following way:

export VAR_NAME=var-value-original

taskctl test-export-as-override
INFO[0000] Running task set-env-value...                
set-env-value: var-value-changed
INFO[0000] set-env-value finished. Duration 200.544µs   
INFO[0000] Running task use-env-value...                
use-env-value: var-value-original
INFO[0000] use-env-value finished. Duration 151.547µs   

Summary:
- Stage set-env-value was completed in 426.211µs
- Stage use-env-value was completed in 482.525µs
Total duration: 100.584622ms

The use-env-value: var-value-original shows that the exportAs did not have any effect.

I use the following taskctl version on Ubuntu 20.04.2 LTS

taskctl -version                
taskctl version 1.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions