gitlab与jenkins结合构建自动化部署系统
gitlab-ce安装-使用国内源
GitLab是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目。
GitLab拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。
1.基础环境准备
[[email protected] ~]# yum install curl policycoreutils openssh-server openssh-clients postfix[[email protected] ~]# systemctl start postfix
2.安装gitlab-ce
curl -sS https://packages.gitlab.com/in ... pm.sh | sudo bash[[email protected] ~]# yum install -y gitlab-ce
注:由于网络问题,国内用户,建议使用清华大学的镜像源进行安装:
[[email protected] ~]# vim /etc/yum.repos.d/gitlab-ce.repo[gitlab-ce] name=gitlab-ce baseurl=http://mirrors.tuna.tsinghua.e ... m/el7repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key[[email protected] ~]# yum makecache[[email protected]x-node2 ~]# yum install gitlab-ce
3.配置并启动gitlab-ce
[[email protected] ~]# gitlab-ctl reconfigure
可以使用gitlab-ctl管理gitlab,例如查看gitlab状态:
[[email protected] ~]# gitlab-ctl status run: gitlab-workhorse: (pid 12171) 231s; run: log: (pid 7817) 555s run: logrotate: (pid 12175) 230s; run: log: (pid 7832) 548s run: nginx: (pid 12181) 230s; run: log: (pid 7823) 549s run: postgresql: (pid 12186) 229s; run: log: (pid 7683) 587s run: redis: (pid 12194) 229s; run: log: (pid 7600) 592s run: sidekiq: (pid 12198) 229s; run: log: (pid 7806) 558s run: unicorn: (pid 14967) 6s; run: log: (pid 7774) 560s 关闭gitlab:[[email protected] ~]# gitlab-ctl stop 启动gitlab:[[email protected] ~]# gitlab-ctl start 重启gitlab:[[email protected] ~]# gitlab-ctl restart
登录gitlab
第一次登录gitlab,需要为root用户修改密码,root用户也是gitlab的超级管理员。
管理gitlab
使用root用户和刚才创建的密码登录后,你就可以探索gitlab的奥秘了,可以点击图中红框的按钮进入管理区域。
持续集成之Jenkins安装部署
安装JDK
Jenkins是Java编写的,所以需要先安装JDK,这里采用yum安装,如果对版本有需求,可以直接在Oracle官网下载JDK。
[[email protected] ~]# yum install -y java-1.8.0
安装Jekins
[[email protected] ~]# cd /etc/yum.repos.d/[[email protected] yum.repos.d]# wget http://pkg.jenkins.io/redhat/jenkins.repo[[email protected] ~]# rpm --import http://pkg.jenkins.io/redhat/jenkins.io.key[[email protected] ~]# yum install -y jenkins[[email protected] ~]# systemctl start jenkins
访问Jenkins
为了安全考虑,首先需要解锁Jenkins,请在/var/lib/jenkins/secrets/initialAdminPassword中查看文件。
[[email protected] ~]# cat /var/lib/jenkins/secrets/initialAdminPassword 98dc4fdeb47641bf93bfbd884d0d9b7f
选择需要安装的插件:
选择默认即可,会安装通用的社区插件,剩下的可以在使用的时候再进行安装。
由于网络原因,有一些插件会安装失败。
设置Admin用户和密码
登陆Jenkins
转载自赵班长博客:https://www.unixhot.com/article/55
转载于:https://blog.51cto.com/chenjisong/1840948