简体   繁体   English

使用Jenkins Build从AWS上的服务器获取文件

[英]Getting files from server on AWS Using Jenkins Build

I have installed jenkins on my local machine (on premises). 我已经在本地计算机(本地)上安装了jenkins。 I have my server (Linux) in AWS Cloud. 我在AWS Cloud中拥有服务器(Linux)。 I need to share logs with developers with out giving server access to them. 我需要与开发人员共享日志,而无需授予服务器访问权限。 I need to create a jenkins job by running that job they should get the logs from server. 我需要通过运行该作业来创建jenkins作业,他们应该从服务器获取日志。

How can i do that ?? 我怎样才能做到这一点 ?? If any one following the same process to get the data from cloud please help me in solving this... Thanks in advance. 如果有人遵循相同的过程从云中获取数据,请帮助我解决此问题。

  1. Use the SSH Agent plugin to securely setup your private key 使用SSH代理插件安全地设置您的私钥
  2. Use SCP to copy the log files to the local workspace 使用SCP将日志文件复制到本地工作空间
  3. Archive those files to the Jenkins job 将这些文件存档到Jenkins工作

You could write a pipeline script to do this. 您可以编写管道脚本来执行此操作。 Something like: 就像是:

node ("linux") {
  sshagent (credentials: ['deploy-dev']) {
    sh 'scp user@awshostnamehere:/somepath/somelogfile .'
    archive somelogfile
  }
}

Note that this requires you to fill in the blanks. 请注意,这要求您填写空白。 To get this to work you would have to: 要使其正常工作,您必须:

  1. Setup an SSH private key credential named deploy-dev 设置一个名为deploy-dev的SSH私钥证书
  2. Setup a build agent with the label 'linux' or change that to a label of an agent you do have. 使用标签“ linux”设置构建代理,或将其更改为您所拥有的代理的标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM