问题描述
我有一份 jenkins 工作,正在构建 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 Desktop/url.txt [email protected]:~/Desktop/url.txt
scp –P 22 Desktop/url.txt [email protected]:~/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 文件复制到差异主机服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!