We have Jenkins Master 2.121.2 with 3 Jenkins Slave nodes. Recently we have encountered the following error:
Failed to connect to repository : Command "git ls-remote -h ssh://email@example.com/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.
After analysis we have discovered the $PATH environment variable is getting corrupt somehow:
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=/
We can not understand which setting change or some plugin setting change caused this.
When I run this command from SSH terminal it works fine, because $PATH variable on VM where Jenkins Master installed has correct value with /usr/bin in it and stuff like that: