Jenkins:某些插件或设置破坏了 PATH 环境变量

Jenkins:某些插件或设置破坏了 PATH 环境变量

我们有 Jenkins Master 2.121.2 和 3 个 Jenkins Slave 节点。最近我们遇到了以下错误:

ssh:在 $PATH 中未找到

Failed to connect to repository : Command "git ls-remote -h ssh://[email protected]/company/project.git HEAD" returned status code 128:
stdout: 
stderr: /tmp/ssh6561150012866430021.sh: 6: /tmp/ssh6561150012866430021.sh: ssh: not found
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

经过分析,我们发现 $PATH 环境变量不知为何损坏了:

JENKINS_HOME=/var/lib/jenkins
GIT_ASKPASS=echo
HUDSON_URL=http://jenkins.company.com/
HUDSON_COOKIE=fead3b34-f36e-4cb6-875b-2ab9462b78d5
JENKINS_SERVER_COOKIE=24409b12678d95d1
SSH_ASKPASS=/tmp/pass5551091293893472212.sh        
GIT_SSH=/tmp/ssh3633673669866483540.sh
HUDSON_HOME=/var/lib/jenkins
JOB_BASE_NAME=company-project
PATH=/usr/lib/git-core:/usr/java/jdk1.8.0_181-amd64/bin
DISPLAY=:
GIT_SSH_VARIANT=ssh
JENKINS_URL=http://jenkins.company.com/
JOB_URL=http://jenkins.company.com/view/company/job/project/
GIT_TERMINAL_PROMPT=0
HUDSON_SERVER_COOKIE=24409b12678d95d1
DOCKER_HOST=tcp://127.0.0.1:2375
JOB_DISPLAY_URL=http://jenkins.company.com/view/company/job/project//display/redirect
JOB_NAME=company-project
JAVA_HOME=/usr/java/jdk1.8.0_181-amd64
PWD=/

我们无法理解哪个设置更改或某些插件设置更改导致了这种情况。

当我从 SSH 终端运行此命令时,它运行正常,因为安装 Jenkins Master 的 VM 上的 $PATH 变量具有正确的值,其中包含 /usr/bin 和类似内容:

ssh [email protected]/company/project.git

相关内容