2

Bellow command if i write inside a script (test.sh) and execute directly on the specific machine it works.

sshpass -p $HOST_PWD sftp testuser@host <<!
cd parent
mkdir test
bye
!

But when i try to run (directly below scrip or invoking the test.sh file in the specif path) in Jenkins with "Execute shall script on remote host using ssh" it failing with

sshpass: Failed to run command: No such file or directory

I have installed sshpass, lftp and rsync in the remote machine

Issue :

  • I have added export $HOST_PWD in .bashrc of specific machine as well as Jenkins but in not finding it
  • Script placed in specific machine, if directly executed the script in that machine it works even with $HOST_PWD. But not working if we invoke from jenkins either script or directly scrip using "Execute shall script on remote host using ssh"

Working with Changes :

  • Instead of $HOST_PWD if i added directly password it works.
R D
  • 1,330
  • 13
  • 30
  • Check that your PATH environment variable contains the directories for these commands. Secondly, `sshpass` runs on the system where you type these commands, so you have to install it on your Jenkins hosting server (you say it is installed on the remove machine, what about your local machine?). – Nic3500 May 26 '21 at 02:46
  • @Nic3500 already I have installed in sshpass, lftp in jenkins machine as well. same issue – R D May 26 '21 at 14:14
  • Try command `which sshpass`. It should show you where `sshpass` is located, if it can find it. On my linux, for exemple, it returns "/usr/bin/sshpass". If it returns nothing, it means you have to add the directory where `sshpass` is located to the user's PATH variable. – Nic3500 May 27 '21 at 00:55
  • @Nic3500 i have updated the description with issue and working changes. Please suggest if you feel anything. – R D May 27 '21 at 04:36
  • Does this answer your question? [How to set environment variables in Jenkins?](https://stackoverflow.com/questions/10625259/how-to-set-environment-variables-in-jenkins) – Nic3500 May 27 '21 at 16:34
  • FYI, if you have another question, create a new post here. Editing a question with something new (other than adding details) risk people not seeing your new question. – Nic3500 May 27 '21 at 16:34

0 Answers0