设为首页 收藏本站
查看: 1997|回复: 0

[经验分享] GitLab+Jenkins部署及实现集成

[复制链接]

尚未签到

发表于 2018-9-16 09:22:03 | 显示全部楼层 |阅读模式
GitLab介绍
  GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。
  系统环境准备
  建议:内存4G以上不然带不动
1234[root@hejianlai-jenkins ~]# cat /etc/redhat-releaseCentOS Linux>[root@hejianlai-jenkins ~]# uname -r3.10.0-693.el7.x86_64  #关闭firewalld和NetWorkManager
12[root@hejianlai-jenkins ~]# systemctl stop firewalld[root@hejianlai-jenkins ~]# systemctl stop NetWorkManager  #永久关闭
12[root@hejianlai-jenkins ~]# systemctl disable firewalld[root@hejianlai-jenkins ~]# systemctl disable NetWorkManager  #关闭selinux
12[root@hejianlai-jenkins ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config[root@hejianlai-jenkins ~]# setenforce 0  #更换阿里源和下载epel源
123[root@hejianlai-jenkins ~]#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup[root@hejianlai-jenkins ~]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo[root@hejianlai-jenkins ~]#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo  #yum源更新,重启系统
1[root@hejianlai-jenkins ~]# yum update && reboot  #安装相应工具
12[root@hejianlai-jenkins ~]yum install curl policycoreutils openssh-server openssh-clients postfix -y[root@hejianlai-jenkins ~]systemctl start postfix  #新建GitLab源
12345678910[root@hejianlai-jenkins ~]# vim /etc/yum.repos.d/gitlab-ce.repo[gitlab-ce]name=gitlab-cebaseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7repo_gpgcheck=0gpgcheck=0enabled=1gpgkey=https://packages.gitlab.com/gpg.key[root@hejianlai-jenkins ~]# yum makecache[root@hejianlai-jenkins ~]# yum install -y gitlab-ce  #安装git工具
1[root@hejianlai-jenkins ~]# yum install git -y  #加载配置文件并启动,时间稍长
1[root@hejianlai-jenkins ~]# gitlab-ctl reconfigure  #gitlab-ctl其他命令
12345启动:gitlib-ctl start关闭:gitlab-ctl stop重启:gitlab-ctl restart重载配置:gitlab-ctl reconfigure查看状态:gitlab-ctl status  #查看端口保证80端口不被占用
1234[root@hejianlai-jenkins ~]# lsof -i:80COMMAND PID       USER   FD   TYPE DEVICE>nginx   700       root    7u  IPv4  16903      0t0  TCP *:http (LISTEN)nginx   804 gitlab-www    7u  IPv4  16903      0t0  TCP *:http (LISTEN)  #gitlab配置文件路径
1/etc/gitlab/gitlab.rb  浏览器登录gitlab,输入http://ip进入下图:

  先输入密码,然后Register填写账户信息进入新建项目

  填写ssh认证

  测试拉取代码
12345678910[root@hejianlai-jenkins ~]# git clone git@hejianlai-jenkins:web/web-demo.gitCloning into 'web-demo'...remote: Counting objects: 6, done.remote: Compressing objects: 100% (3/3), done.remote: Total 6 (delta 0), reused 0 (delta 0)Receiving objects: 100% (6/6), done.[root@hejianlai-jenkins ~]# lsanaconda-ks.cfg  epel-release-latest-7.noarch.rpm  web-demo[root@hejianlai-jenkins ~]# ls web-demo/index.html  README.md  上传代码
12345678910111213141516171819202122232425262728293031[root@hejianlai-jenkins web-demo]# echo "test" >>test.txt [root@hejianlai-jenkins web-demo]# git config --global user.email "you@example.com"[root@hejianlai-jenkins web-demo]# git config --global user.name "Your Name"[root@hejianlai-jenkins web-demo]# git add *[root@hejianlai-jenkins web-demo]# git commit -m "add test.txt"[master 5df66f7] add test.txt 1 file changed, 1 insertion(+) create mode 100644 test.txt[root@hejianlai-jenkins web-demo]# git pushwarning: push.default is unset; its implicit value is changing inGit 2.0 from 'matching' to 'simple'. To squelch this messageand maintain the current behavior after the default changes, use:   git config --global push.default matching To squelch this message and adopt the new behavior now, use:   git config --global push.default simple See 'git help config' and search for 'push.default' for further information.(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode'current' instead of 'simple' if you sometimes use older versions of Git) Counting objects: 4, done.Delta compression using up to 2 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 314 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)To git@hejianlai-jenkins:web/web-demo.git   18a57cf..5df66f7  master -> master  GitLab上查看:

  #安装JenKins
123456789[root@hejianlai-jenkins web-demo]# sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo [root@hejianlai-jenkins web-demo]# sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key[root@hejianlai-jenkins web-demo]# yum install java jenkins –y#JenKins默认端口为8080,因为gitlab已经占用我们需要更改。 [root@hejianlai-jenkins web-demo]# vim /etc/sysconfig/jenkins JENKINS_PORT="8080"  ---> JENKINS_PORT="8081"  #启动JenKins
12[root@hejianlai-jenkins web-demo]# /etc/init.d/jenkins startStarting jenkins (via systemctl):                          [  OK  ]  #浏览器登录JenKins,地址:http://192.168.247.135:8081/
  正在启动;

  进入有个密码路径,系统上查看这个文件并把密码复制粘贴才能登录;


  选择推荐安装;

  创建一个管理员

  开始使用jenkins

  下面实现持续集成
  进入主页--创建一个新任务

  输入项目名称---构建一个自由风格的软件项目---确认

  General--填写项目描述

  源码管理--安装git插件--授权认证

  ssh私钥认证我们在系统上查看粘贴进去即可。


  Credentials—选择root

  查看gitlab版本
12[root@hejianlai-jenkins ~]# rpm -aq|grep gitlabgitlab-ce-10.6.0-ce.0.el7.x86_64

  点击立即构建

  点击控制台输出查看

  控制台输出,SUCCESS则构建成功

  转载地址:https://www.cnblogs.com/Dev0ps/p/8663262.html


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-584395-1-1.html 上篇帖子: 【Android stuido】【Monkey】【Jenkins】自动化测试初探 下篇帖子: 基于k8s、docker、jenkins构建springboot服务
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表