如何将已从jenkins构建的文件或jar文件复制到diff主机服务器 [英] How to copy a file or jar file that has built from jenkins to a diff host server

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

问题描述

某人正在从事詹金斯工作,正在构建一个jar文件.构建完成后,我需要将该jar文件复制到其他服务器,然后将其部署到该服务器.

Am having a jenkins job where am building a jar file. after the build is done I need to copy that jar file to a different server and deploy it there.

我正在尝试使用此yml文件来实现相同的功能,但它正在jenkins服务器以外的其他服务器中寻找该文件.

Am trying this yml file to achieve the same but it is looking for the file in the different server other than the jenkins server.

---
# ansible_ssh_private_key_file: "{{inventory_dir}}/private_key"
 - hosts: host
   remote_user: xuser
   tasks:
    - service: name=nginx state=started
      become: yes
      become_method: sudo
   tasks:
    - name: test a shell script
      command: sh /home/user/test.sh
   tasks:
    - name: copy files
      synchronize:
           src: /var/jenkins_home/hadoop_id_rsa
           dest: /home/user/

您能否建议使用jenkins部署将构建文件复制到服务器的任何其他方法或方法?

could you please suggest is there any other way or what could be approach to copy a build file to the server using jenkins to deploy.

谢谢.

推荐答案

在构建步骤中使用远程ssh脚本,无需插件

Use remote ssh script in the build step no plug in is required

scp –P 22桌面/url.txt用户@ 192.168.1.50:〜/桌面/url.txt

scp –P 22 Desktop/url.txt user@192.168.1.50:~/Desktop/url.txt

设置密码较少的身份验证,请使用以下链接获取帮助

Setup passwords less authentication use the below link for help

https://www.howtogeek.com/66776/how-to-remotely-copy-files-over-ssh-without-entering-your-password/

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

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