> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trainy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment Variables

> Example task yamls for envs

This example demonstrates several different ways to declare and use environment variables in Konduktor.
Specifically, it demonstrates environment variable setup and use with CLI and task (`task.yaml`) methods.
This example does not include environment secret (`konduktor secret create --kind=env`) or config (`~/.konduktor/config.yaml`) environment variables.
For more details on all methods, check out the explanation of environment variables <a href="/env-vars" target="_blank">here</a>.

## Prerequisites

#### Setup

1. Create shell variable with `export EXPORT_VAR="test1"` before launching or during launch (as shown below)

#### Current Working Directory

```
$ ls
task.yaml
```

#### Launching

```
$ export EXPORT_VAR="test1" && konduktor launch --env EXPORT_VAR --env INLINE_VAR="test2" task.yaml
```

## Task.yaml

```
name: env

resources:
  cpus: 1
  memory: 1
  image_id: ubuntu
  labels:
    kueue.x-k8s.io/queue-name: user-queue
    maxRunDurationSeconds: "3200"

envs:
  TEST_VAR: "test3"

run: |
  if [[ -z "${EXPORT_VAR}" ]]; then
    echo "EXPORT_VAR is not set"
    exit 1
  else
    echo "EXPORT_VAR is set to ${EXPORT_VAR}"
  fi
  if [[ -z "${INLINE_VAR}" ]]; then
    echo "INLINE_VAR is not set"
    exit 1
  else
    echo "INLINE_VAR is set to ${INLINE_VAR}"
  fi
  if [[ -z "${TEST_VAR}" ]]; then
    echo "TEST_VAR is not set"
    exit 1
  else
    echo "TEST_VAR is set to ${TEST_VAR}"
  fi
```
