插件官网:SSH Pipeline Steps

此插件可通过SSH在远程服务器执行命令和传输文件。

pipeline代码,本例是取一个zip文件。为了提高安全性用Credentials Plugin屏蔽用户名密码。Credentials Plugin配置

	  withCredentials([usernamePassword(credentialsId: 'JMeter_Master', passwordVariable: 'password', usernameVariable: 'username')]) {
			script {
				def remote = [:]
				remote.name = 'jmeter'
				remote.host = '192.168.1.11'
				remote.user = "$username"
				remote.password = "$password"
				remote.allowAnyHosts = true
				
				sshGet remote: remote, from: "/opt/jmeter-JTLReport/${JOB_BASE_NAME}/$REPORT_JTL_FILE", into: "${env.WORKSPACE}", override: true
				sshGet remote: remote, from: "/opt/jmeter-ZIPReport/${JOB_BASE_NAME}/$REPORT_ZIP_FILE", into: "${env.WORKSPACE}", override: true
			}
       }
    }
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐