# How to set environment in a remote pipeline

**URL:** <https://community.okteto.com/t/how-to-set-environment-in-a-remote-pipeline/900>\
**Category:** How Do I?\
**Created:** [July 6, 2023, 1:34pm UTC](https://community.okteto.com/t/how-to-set-environment-in-a-remote-pipeline/900 "2023-07-06T13:34:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![florisie](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/florisie/32/423_2.png) [@florisie](https://community.okteto.com/u/florisie)\
**Post date:** [July 6, 2023, 1:34pm UTC](https://community.okteto.com/t/how-to-set-environment-in-a-remote-pipeline/900/1 "2023-07-06T13:34:51Z")

</div>

With a “regular” okteto deploy we can control the pipeline through environment variables. This can be done as far as I know by either running:

```auto
ENV_VAR=xxx okteto deploy

```

or by running:

```auto
okteto deploy -v ENV_VAR=xxx

```

However when we specify an image in the deploy section, and therefore run a remote pipeline, the environment variables do not seem to be propagated to the remote environment. Therefore I am not able to control the flow of the remote pipeline through environment variables.

Thus when the deploy section looks as following:

```auto
deploy:
  image: IMAGE
  commands:
    - echo $TEST_VAR

```

And then run:

```auto
okteto deploy -v TEST_VAR=test-value

```

then the value of TEST\_VAR in the remote pipeline will not be set.

How can I pass environment variables to a remote pipeline?

---

<div class="post-metadata">

**Author:** ![AgustinRamiroDiaz](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/agustinramirodiaz/32/34_2.png) [@AgustinRamiroDiaz](https://community.okteto.com/u/AgustinRamiroDiaz)\
**Post date:** [July 7, 2023, 12:29pm UTC](https://community.okteto.com/t/how-to-set-environment-in-a-remote-pipeline/900/2 "2023-07-07T12:29:14Z")

</div>

Hi @florisie

I’ve been able to make it work with the last option you mentioned in okteto CLI 2.16.4 and 2.17.0

```auto
# okteto.yml
deploy:
  image: busybox
  commands:
    - echo $TEST_VAR

```

```auto
$ okteto deploy -v TEST_VAR=test-value 
 i Using endpoints-test @ okteto.agustin.dev.okteto.net as context
 i Build section is not defined in your okteto manifest
 i Running stage 'echo $TEST_VAR'
Executing command 'echo $TEST_VAR'...
test-value
Command 'echo $TEST_VAR' successfully executed

```

Note that `ENV_VAR=xxx okteto deploy` is not working for me either.

---

<div class="post-metadata">

**Author:** ![florisie](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/florisie/32/423_2.png) [@florisie](https://community.okteto.com/u/florisie)\
**Post date:** [July 9, 2023, 8:40am UTC](https://community.okteto.com/t/how-to-set-environment-in-a-remote-pipeline/900/3 "2023-07-09T08:40:33Z")

</div>

I have no idea what I did wrong before. I mean, I believe I have tried exactly those ways as described in my question (and thus also the way as you describe in your answer) but I could not get it to work at the time when I wrote this question. Now I try it again to verify that indeed it does not work for me (without updating, I’m still on okteto cli 2.16.2) but now suddenly it works.

Again, no idea what I was doing wrong/different at the time that I wrote this question but I’m happy to learn that it actually does work, even on a previous version of okteto cli.

Thank you for taking the time to test it and showing me that it actually just works!

---

<div class="post-metadata">

**Author:** ![AgustinRamiroDiaz](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/agustinramirodiaz/32/34_2.png) [@AgustinRamiroDiaz](https://community.okteto.com/u/AgustinRamiroDiaz)\
**Post date:** [July 10, 2023, 12:17pm UTC](https://community.okteto.com/t/how-to-set-environment-in-a-remote-pipeline/900/4 "2023-07-10T12:17:37Z")

</div>

Your welcome!

Here’s the docs to the usage of the -v command (or --var) [Okteto CLI | Okteto Documentation](https://www.okteto.com/docs/reference/cli/#options)

In case you think there’s something to add, you can propose a PR to [GitHub - okteto/docs](https://github.com/okteto/docs)
