M. Mourad M. Mourad - 1 year ago 261
Bash Question

docker-compose, export environnement variables are not working in Jenkins

I have a docker-compose.yml file with differents variables

version: "2"

image: "${registryUrl}/data:${image_version}"

In my shell, I export registryUrl & image_version

export registryUrl=zhcjie.distribution.ata.com:8652
export image_version=1.0-SNAPSHOT
docker-compose up

that's work in my local (I'm using boot2Docker) but it doesn't work in Jenkins. I have a wrong message.

The registryUrl variable is not set. Defaulting to a blank string.
The image_version variable is not set. Defaulting to a blank string.

I try to pass env variable with EnvInject plugin, it doesn't work too.

Answer Source

Your environment variables inside jenkins shell will not be imported automatically. Add environment variables through .env file under your Jenkins job's workspace.

$ cat .env registryUrl=zhcjie.distribution.ata.com:8652 image_version=1.0-SNAPSHOT

Then run

docker-compose up

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download