jenkins+Ansible联动使用

2021-03-11 14:23:24 浏览数 (1)

Ansible部署文档连接:https://cloud.tencent.com/developer/article/1777892

配置文档:

代码语言:javascript复制
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到指定文件夹

代码语言:javascript复制
/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部署配置

代码语言:javascript复制
cd /var/jenkins_home/workspace/ansible && ansible-playbook shengxian-deployment.yaml --extra-vars "{'host':'${host}','jar':'${target_jar}','server':'${server}'}"

配置完成选择构建就ok

0 人点赞