java.lang.NoSuchMethodError: No such DSL method 'publishOverSsh' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, getContext, git, input, isUnix, libraryResource, load, mail, milestone, node, parallel, properties, pwd, readFile, readTrusted, resolveScm, retry, script, sh, sleep, stage, stash, step, svn, timeout, timestamps, tool, unarchive, unstash, waitUntil, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer,
I used SCP and SSH on remote machine using Jenkins groovy DSL, using Sh:shell script.
Before that use ssh-keygen
to create connection between host machine and Jenkins for password less authentication.
For SSH login without password:
1) create ssh public and private key using ssh-keygen with this command:
$ssh-keygen
2) Copy the public key to remote-host in .ssh/authorized_keys
file.
3) Now login to remote machine with out password.
Now to publish package to remote server use below command in Jenkinsfile script box :
sh 'scp -r ./tests ubuntu@HOST_IP/URL:/home/ubuntu/'
//to execute commands over ssh on remote host which is written in test-script.sh file
sh 'ssh ubuntu@HOST_IP/URL < test-script.sh'
// For echo environmental variables BUILD_ID
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"