问题描述
我有一个具有不同变量的docker-compose.yml文件
I have a docker-compose.yml file with differents variables
version: "2"
services:
data:
image: "${registryUrl}/data:${image_version}"
在我的shell中,我导出registryUrl& 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
这在我的本地(我使用的是boot2Docker),但它没有在詹金斯工作。我有一个错误的信息。
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.
我尝试使用EnvInject插件传递env变量,它也不起作用。
I try to pass env variable with EnvInject plugin, it doesn't work too.
推荐答案
您不会自动导入jenkins shell中的环境变量。通过Jenkins作业工作区下的 .env 文件添加环境变量。
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
然后执行
docker-compose up
这篇关于码头组合,出口环境变量在Jenkins不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!