如何在Jenkinsfile上使用ssh上的ssh发布,以及在Jenkinsfile上使用groovy SDL使用scp?

Kul*_*wal 4 jenkins jenkins-2

java.lang.NoSuchMethodError:在步骤[归档,bat,build,catchError,checkout,deleteDir,dir,dockerFingerprintFrom,dockerFingerprintRun,echo,emailext,emailextrecipients,envVarsForTool,错误,fileExists,getContext,git中没有找到这样的DSL方法'publishOverSsh',输入,isUnix,libraryResource,负载,邮件,里程碑,节点,并行,属性,pwd,readFile,readTrusted,resolveScm,重试,脚本,sh,sleep,阶段,存储,步骤,svn,超时,时间戳,工具,未归档,取消隐藏,waitUntil,withContext,withCredentials,withDockerContainer,withDockerRegistry,withDockerServer,

Kul*_*wal 5

我使用Sh:shell脚本,使用Jenkins groovy DSL在远程计算机上使用了SCP和SSH。

在此之前,用于ssh-keygen在主机和Jenkins之间创建连接以进行少密码验证。

对于没有密码的SSH登录:

1)通过以下命令使用ssh-keygen创建ssh公钥和私钥:

$ssh-keygen
Run Code Online (Sandbox Code Playgroud)

2)将公钥复制到中的远程主机。ssh/authorized_keys文件。

3)现在,不用密码登录到远程计算机。

现在要将包发布到远程服务器,请在Jenkinsfile脚本框中使用以下命令:

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}"
Run Code Online (Sandbox Code Playgroud)