0

We have Jenkins Master 2.121.2 with 3 Jenkins Slave nodes. Recently we have encountered the following error:

ssh: not found in $PATH

Failed to connect to repository : Command "git ls-remote -h ssh://git@gitlab.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:

ssh git@gitlab.com/company/project.git
  • I would try to look for the new PATH string within the configuration files. – mrg2k8 Jan 15 at 14:03
  • There isn't enough content in your question to be able to tell what's causing the issues with PATH. If you are using Pipeline (i.e. Jenkinsfiles), could you please update your question with the contents of your Jenkinsfile? Otherwise, could you please post a screenshot of your job configuration? – jayhendren Jan 15 at 18:16
  • This happens before Pipeline (Jenkinsfile), I mean before running Build Job. The screenshot I have posted is from Maven-type job. It happens on Jenkins Master. From UI I'm trying to add Git repository, Git client plugin tries to connect to git repository github.com/jenkinsci/git-client-plugin/blob/master/src/main/… . – Rafis Ganeev Jan 16 at 11:00
  • 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. – Rafis Ganeev Jan 16 at 14:10
  • I think this question is related somehow stackoverflow.com/questions/50763421/… – Rafis Ganeev Jan 28 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.