jenkins远程部署tocmat
0:环境
注:图片的名字
jenkins主机ip:192.168.1.164
远程主机ip:192.168.1.200
1:采用war包部署

jenkins(1.164)->web端点击项目中左侧构建->jenkins去git代码仓库通过用户名密码的方式下载项目的源代码到jenkins本地->通过jenkins上的maven的命令打成war包->通过构建后操作中写入tomcat的url地址及用户名密码发到->远程服务器上tomcat的webapps下并覆盖原先的war包->刷新http://192.168.1.200:8080项目的页面,ok完成。
1.200tomcat上配置
vim /opt/apache-tomcat/conf/tomcat-users.xml
修改tomcat配置(webapps下必须有manage文件夹,其他文件可删除,防火墙允许8080端口)
<role rolename ="admin,manager,manager-script,manager-gui"/>
<user username= "admin" password= "admin" roles ="admin,manager,manager-script,manager-gui"/>

jenkins WEB端配置






vim /usr/local/nginx/conf.d/conf/test.conf
server{
listen 80;
server_name 192.168.1.200;
client_max_body_size 60M;
client_body_buffer_size 512k;
location / {
proxy_pass http://192.168.1.200;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
allow 192.168.1.0/24;
deny all;
}
location /manager {
return 404;
}
}
主要就是后面一个location,如果是域名,当别人以域名的方式访问报404,以ip端口访问时是正常的
2:采用ssh部署








2中的脚本就不提供了也就是简单的服务更新部署操作,这种纯属因人和项目而不同。