# Using stages from Environment Variable

**URL:** <https://community.grafana.com/t/using-stages-from-environment-variable/98897>\
**Category:** OSS Support\
**Created:** [March 9, 2020, 1:19pm UTC](https://community.grafana.com/t/using-stages-from-environment-variable/98897 "2020-03-09T13:19:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulfairless](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/paulfairless/32/36162_2.png) [@paulfairless](https://community.grafana.com/u/paulfairless)\
**Post date:** [March 9, 2020, 1:19pm UTC](https://community.grafana.com/t/using-stages-from-environment-variable/98897/1 "2020-03-09T13:19:42Z")

</div>

Hello,

Running into an issue when trying to use stages with an Environment variable. It does not set max users or iterations as it does when using options variable inside test script.

`docker run -e K6_STAGE="10s:10,2m:30,30s:0" -i loadimpact/k6 run --include-system-env-vars=true - <script.js`

```auto
  execution: local--------------------------------------------------] servertor
     output: -
     script: -

    duration: -, iterations: 1
         vus: 1, max: 1

```

sets iterations to `1` and max to 1. This causes the test not to run through the full set of stages and finish early. vs

```auto
export let options = {
    stages: [
        { duration: '10s', target: 10 },
        { duration: '2m', target: 30 },
        { duration: '30s', target: 0 },
    ]
};

```

sets iterations to `-` and max to 30

```auto
  execution: local--------------------------------------------------] servertor
     output: -
     script: -

    duration: -, iterations: -
         vus: 1, max: 30

```

I could set max manually to the required value, but have no idea how to set iterations to the equivalent of `-`.

Any advice appreciated

---

<div class="post-metadata">

**Author:** ![mstoykov](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/mstoykov/32/35309_2.png) [@mstoykov](https://community.grafana.com/u/mstoykov)\
**Post date:** [March 9, 2020, 1:38pm UTC](https://community.grafana.com/t/using-stages-from-environment-variable/98897/2 "2020-03-09T13:38:36Z")

</div>

Hi @paulfairless

the correct env variable is `K6_STAGES` not `K6_STAGE` 😉

Also, I am pretty sure you don’t need `--include-system-env-vars=true`, it is already true for `k6 run`, but you will need it for `k6 cloud` as it is false there 🙂

---

<div class="post-metadata">

**Author:** ![paulfairless](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/paulfairless/32/36162_2.png) [@paulfairless](https://community.grafana.com/u/paulfairless)\
**Post date:** [March 9, 2020, 1:57pm UTC](https://community.grafana.com/t/using-stages-from-environment-variable/98897/3 "2020-03-09T13:57:28Z")

</div>

Thanks, I should have just tried that i suppose.

The github readme has examples using `K6_STAGE` which is how i was was getting thrown off the scent.

All works as expected now, thanks for the help

---

<div class="post-metadata">

**Author:** ![nedyalko](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@nedyalko](https://community.grafana.com/u/nedyalko)\
**Post date:** [March 9, 2020, 2:01pm UTC](https://community.grafana.com/t/using-stages-from-environment-variable/98897/4 "2020-03-09T14:01:23Z")

</div>

🤦‍♂️ sorry about that, we’ll fix the README 😊

---

<div class="post-metadata">

**Author:** ![mstoykov](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/mstoykov/32/35309_2.png) [@mstoykov](https://community.grafana.com/u/mstoykov)\
**Post date:** [March 9, 2020, 2:22pm UTC](https://community.grafana.com/t/using-stages-from-environment-variable/98897/5 "2020-03-09T14:22:04Z")

</div>

updated in [eebe92db](https://github.com/loadimpact/k6/commit/eebe92dbf587f81d057663cd6a17b607c1144682)
