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

扶醉桌前 提交于 2019-12-11 01:57:15

问题


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

version: "2"
services:

  data:
    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.


回答1:


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



来源:https://stackoverflow.com/questions/38992589/docker-compose-export-environnement-variables-are-not-working-in-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!