# Rancher Pipeline: How to pass environment variables from one stage to another

Currently I am trying to move our existing build infrastructure to Rancher with its CICD pipelines.

My main question is: Is it possible to pass environment variables from one stage to another?

Our application is Java / Spring based (so there is a pom.xml containing information like version). I am trying to extract information like VERSION and CHANNEL (=snapshot or release), which are needed in the next step ('build and deploy image'), since we need to provide some environment variables to the 'docker build' command.

I know that its possible to pass data via the working directory, which is shared by all containers. Unfortunately you only can pass environment variables to the 'docker build' command in the 'build and deploy image' stage via 'PLUGIN_BUILD_ARGS' variable (https://rancher.com/docs/rancher/v2.x/en/k8s-in-rancher/pipelines/#build-and-publish-images). Also I do not see that its possible to run a script in the 'build and deploy image' container to provide those environment variables.

I also know that there is a list of environment variables provided by rancher (https://rancher.com/docs/rancher/v2.x/en/k8s-in-rancher/pipelines/#pipeline-variable-substitution-reference), but none of those variables helps me. Is it somehow possible to extend that list?

I already tried to pass variables, but it did not work:

stages:
- name: export
steps:
- runScriptConfig:
image: maven
shellScript: |-
export FOO="bar"
- name: echo
steps:
- runScriptConfig:
image: maven
shellScript: |-
env
echo \${FOO}
timeout: 60