gpt4 book ai didi

docker - 工作从哪里获取环境变量?

转载 作者:行者123 更新时间:2023-12-02 19:40:21 25 4
gpt4 key购买 nike

当我在go-agent上执行printenv命令时

go@05f749b73185:/tmp$ printenv
HOSTNAME=05f749b73185
SHELL=/bin/bash
USER=go
LS_COLORS=
MAVEN_VERSION=3.3.9
MAIL=/var/mail/go
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
MAVEN_HOME=/usr/share/maven
PWD=/tmp
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
LANG=en_US.UTF-8
HOME=/var/go
SHLVL=2
LOGNAME=go
LC_CTYPE=en_US.UTF-8
LESSOPEN=| /usr/bin/lesspipe %s
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/printenv

但是,当我从作业内部执行printenv命令时,会得到此结果
06:57:26.482 [go] Start to execute task: <exec command="printenv" />.
06:57:26.493 GO_SERVER_URL=https://go-server:8154/go/
06:57:26.493 JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
06:57:26.494 SHLVL=2
06:57:26.494 MAVEN_HOME=/usr/share/maven
06:57:26.495 LOG_DIR=/var/log/go-agent
06:57:26.495 GO_TRIGGER_USER=anonymous
06:57:26.495 GO_SERVER=go-server
06:57:26.496 GO_PIPELINE_LABEL=8
06:57:26.496 GO_STAGE_NAME=build
06:57:26.497 HOSTNAME=05f749b73185
06:57:26.497 PWD=/var/lib/go-agent
06:57:26.498 GO_STAGE_COUNTER=1
06:57:26.498 AGENT_WORK_DIR=/var/lib/go-agent
06:57:26.499 GO_JOB_NAME=Compile
06:57:26.499 MAVEN_VERSION=3.3.9
06:57:26.499 OLDPWD=/etc/service/go-agent
06:57:26.500 LC_CTYPE=en_US.UTF-8
06:57:26.500 AGENT_STARTUP_ARGS=-Dcruise.console.publish.interval=10 -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom
06:57:26.501 GO_FROM_REVISION=b6f8f0f3bedabe1cc0ffa1334c290f32da723cde
06:57:26.501 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
06:57:26.501 GO_TO_REVISION=b6f8f0f3bedabe1cc0ffa1334c290f32da723cde
06:57:26.502 USER=go
06:57:26.502 GO_SERVER_PORT=8153
06:57:26.502 GO_PIPELINE_NAME=DropwizardSeed
06:57:26.503 HOME=/var/go
06:57:26.503 UID=103
06:57:26.503 GO_ENVIRONMENT_NAME=local
06:57:26.506 INITRD=no
06:57:26.507 GO_PIPELINE_COUNTER=8
06:57:26.508 GO_REVISION=b6f8f0f3bedabe1cc0ffa1334c290f32da723cde
06:57:26.509 LANG=en_US.UTF-8

如果查看JAVA_HOME环境变量,则在作业调用和登录计算机时直接调用之间有所不同。
这可以通过在管道中设置环境变量来解决,但是如何配置我的go-server和go-agents,所以我不必这样做?如果我想使用另一个JDK作为默认值怎么办?

JAVA_HOME环境变量来自哪里?

最佳答案

您检查了/etc/default/<agent-name>
在此文件中,您可以定义代理的默认值,也可以使用export命令定义环境变量。

关于docker - 工作从哪里获取环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38007661/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com