1:环境配置
Debian 3.16.43
jenkins2.121.1
2:描述
前端开发人员想代码提交到gitlab然后自动发布到线上服务器,于是调用gitlab的webhooks来直接调用jenkins项目发布到线上
3:开始部署 (此处以 自由风格构 建方式)
3.1 创建项目
3.2 填写仓库地址
3.3 重点来了 (选择构建触发器)
Build when a change is pushed to GitLab. GitLab CI Service URL: http://ip:8090/project/xuqiu 选择开启
3.4 其他的需要根据自己的环境进行选择使用 我这里就调用脚本实现发布的
4: 然后点击保存 即可 jenkins配置完毕 现在到gitlab上调用webhooks来发布jenkins
找到对应的项目->settings->intergrations
填写调用的webhooks调用的gitlab的信息
5 重新提交代码到gitlab仓库 查看调用情况
6:nginx代理jenkins访问 屏蔽直接端口访问
server {
listen 80;
server_name hanye.com;
access_log /data/wwwlogs//jenkins-web.access.log ;
error_log /data/wwwlogs//jenkins-web.error.log;
# auth_basic "Nginx";
# auth_basic_user_file /usr/local/nginx/conf/passwd;
# autoindex on;
location / {
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;
proxy_pass http://192.168.1.252:8090;
}
}
记住防火墙做好限制
7:设置jekins域名访问
系统管理>系统设置>Jenkins Location> Jenkins URL修改为域名访问
在设置job的2设置
转载于:https://blog.51cto.com/9025736/2319210