Issue
I am trying to run Jenkins job, To put the Jenkins parameters on different server, so i can run commands on the remote server , with parameters set in the Jenkins, executing shell . I am trying to transferring the parameters via here-doc
Trying this code:
echo $BUILD_USER_ID $BUILD_DISPLAY_NAME
echo $servers > /tmp/servers.txt
for servers in `cat /tmp/servers.txt`; do
ssh -T $servers <<'EOF'
echo ${BUILD_NUMBER} ${BUILD_USER_ID} >/tmp/test
EOF
done < /tmp/log.txt > ${LOG}
Solution
You should be able to use SSH Pipeline Steps for this.
def remote = [:]
remote.name = 'test'
remote.host = 'test.domain.com'
remote.user = 'root'
remote.password = 'password'
remote.allowAnyHosts = true
stage('Remote SSH') {
sshCommand remote: remote, command: "ls -lrt"
sshCommand remote: remote, command: "for i in {1..5}; do echo -n \"Loop \$i \"; date ; sleep 1; done"
}
Answered By - ycr
Answer Checked By - Robin (JavaFixing Admin)