How to copy a file or jar file that has built from jenkins to a diff host server

我的未来我决定 提交于 2019-12-23 04:36:39

问题


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.

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/

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.

Thanks.


回答1:


Hi as per my knowledge you can use Publish Over ssh plugin in jenkins. actually i am not clear about your problem. but hoping that this can help you. plugin details: https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+SSH+Plugin if it wont help you, please comment. can you please more specific. (screen shot if possible)




回答2:


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

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/



来源:https://stackoverflow.com/questions/44128009/how-to-copy-a-file-or-jar-file-that-has-built-from-jenkins-to-a-diff-host-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!