如何将文件从 SSH 远程主机复制到 Jenkins 服务器 [英] How to copy file from SSH remote host to Jenkins Server

查看:30
本文介绍了如何将文件从 SSH 远程主机复制到 Jenkins 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在日常构建过程中使用 Jenkins 服务器,并通过 SSH 在远程主机上执行一些 bash 脚本.此脚本在远程主机上生成 html 日志文件.

We are using Jenkins server for our daily build process and executes some bash scripts on remote hosts over SSH. This scripts are generating html log files on remote hosts.

我们使用复制到slave插件来在从机上复制文件和 通过 ssh 发布 插件到在构建过程中管理 SSH 会话.

We are using Copy to slave plugin to copy files on slave machines and Publish over ssh plugin to manage SSH sessions in build process.

现在的问题是,我们想将一些文件(脚本的日志文件)从远程 ssh 主机复制到 Jenkins 服务器.对于相同的情况,哪个是可能的和更好的选择(如果有插件会更好).

Now the question is, We want to copy some files (log files of Scripts) from remote ssh host to Jenkins Server. Which will be possible and better option for the same (plugin will be better if any).

sshpass 是一个选项,但正在寻找任何插件或更好的方法来完成这项工作.

sshpass is an option, but looking for any plugin or better way to do the job.

推荐答案

use sshpass 命令发送文件到

use sshpass command to send file in

构建环境 -> 使用 ssh 在远程主机上执行 Shell 脚本 ->构建后脚本

Build Environment -> Execute Shell script on remote host using ssh -> Post build script

示例命令:

sshpass -p "password" scp path/of/file <new_server_ip>:/path/of/file

这将跳过 scp 命令的密码提示,并将为 scp 提供密码.

This will skip password prompt for scp command and will provide password to scp.

这篇关于如何将文件从 SSH 远程主机复制到 Jenkins 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆