# How to prevent agents from inheriting environment variables from controller?

**URL:** <https://community.jenkins.io/t/how-to-prevent-agents-from-inheriting-environment-variables-from-controller/3871>\
**Category:** Using Jenkins\
**Created:** [September 20, 2022, 8:10pm UTC](https://community.jenkins.io/t/how-to-prevent-agents-from-inheriting-environment-variables-from-controller/3871 "2022-09-20T20:10:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakauppila](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/jakauppila/32/314_2.png) [@jakauppila](https://community.jenkins.io/u/jakauppila)\
**Post date:** [September 20, 2022, 8:10pm UTC](https://community.jenkins.io/t/how-to-prevent-agents-from-inheriting-environment-variables-from-controller/3871/1 "2022-09-20T20:10:10Z")

</div>

Is there a way to prevent agents from inheriting the environment variables that are defined on the controller?  
We’d like to keep the execution environment pretty clean for our ephemeral agents and there’s a lot of values pushed in from the controller that we would like to filter out.

---

<div class="post-metadata">

**Author:** ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)\
**Post date:** [September 20, 2022, 9:12pm UTC](https://community.jenkins.io/t/how-to-prevent-agents-from-inheriting-environment-variables-from-controller/3871/2 "2022-09-20T21:12:17Z")

</div>

I don’t think this is possible. You can override variables and add to variables, but I don’t think you can say don’t use any variables.

---

<div class="post-metadata">

**Author:** ![halkeye](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/halkeye/32/8_2.png) [@halkeye](https://community.jenkins.io/u/halkeye)\
**Post date:** [September 20, 2022, 9:16pm UTC](https://community.jenkins.io/t/how-to-prevent-agents-from-inheriting-environment-variables-from-controller/3871/3 "2022-09-20T21:16:10Z")

</div>

Also, which env variables? Which plugin for ephemeral agents?

---

<div class="post-metadata">

**Author:** ![jakauppila](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/jakauppila/32/314_2.png) [@jakauppila](https://community.jenkins.io/u/jakauppila)\
**Post date:** [September 20, 2022, 10:03pm UTC](https://community.jenkins.io/t/how-to-prevent-agents-from-inheriting-environment-variables-from-controller/3871/4 "2022-09-20T22:03:24Z")

</div>

Disregard, user error.

We’re using the [Amazon ECS plugin](https://plugins.jenkins.io/amazon-ecs/) to run both our controller and agents on AWS ECS with Fargate.

Our deployment process sets a number of environment variables on the task definitions for both, and it appears we forgot to remove some variables on the agent task definitions so I incorrectly thought they were coming from the controller.

I did a test where I explicitly set an environment variable on the controller task definition and can see it in the system information but it does not propagate to the agent.
