rsync command is not working when executing it from a remote host. Jenkins node tries to execute few commands on a remote server, but when running the rsync command I am getting below error
sh: rsync: not found.
The rsync command works successfully when I run directly on that server, but when I run it through ssh, it is giving the above error
This is the command that is failing
ssh root@"$build_server" "rsync -avzh $SRC_DIR/main $BUILD_DIR || exit 1"
I tried by giving the path of rsync but still the same error
ssh root@"$build_server" "rsync -avzh --rsync-path=/usr/local/bin/rsync $SRC_DIR/main $BUILD_DIR || exit 1"
Check the remote server's PATH environment variable: Jenkins executes commands in a shell environment, and the error indicates that the shell cannot find the rsync executable. Ensure that the PATH environment variable is properly set on the remote server.
So either you modify your environment or you specify the full path to the rsync executable: If rsync is installed in a non-standard location or the PATH is not set correctly, you can specify the full path to the rsync executable in your Jenkins job or script.