Ansible部署文档连接:https://cloud.tencent.com/developer/article/1777892
配置文档:
cat shengxian-deployment.yaml
---
- hosts: '{{host}}'
tasks:
- name: back
shell: mv /home/project/fresh/{{jar}} /home/project/fresh/{{jar}}.back
- name: scp
copy:
src: /var/jenkins_home/workspace/ansible/shengxian/{{jar}}
dest: /home/project/fresh/{{jar}}
- name: restart
shell: supervisorctl restart '{{server}}'
jenkins部署大家百度吧。
jenkins配置:
打包配置
打完包cp到指定文件夹
/var/jenkins_home/maven-3.6.1-8u212/bin/mvn clean package -Dmaven.test.skip=true
cp biz-web/target/prj-fresh-biz-web-*.jar ../ansible/shengxian/uat-prj-fresh-biz-web.jar
jenkins部署配置
cd /var/jenkins_home/workspace/ansible && ansible-playbook shengxian-deployment.yaml --extra-vars "{'host':'${host}','jar':'${target_jar}','server':'${server}'}"
配置完成选择构建就ok