ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
:-: 服务器列表(虚拟机统一采用CentOS7) |名称 |主机名 |安装的软件| |----|----|----| |<mark>代码托管服务器</mark>| gitlab-master |gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm| |持续集成服务器| jenkins-master |Jenkins-2.190.3、JDK1.8、Maven3.6.2、Git、SonarQube| |应用测试服务器| tomcat-master |JDK1.8、Tomcat8.5| <br/> [TOC] # 1. Gitlab代码托管服务器安装 **1. 安装相关依赖** ```shell yum -y install policycoreutils policycoreutils-python openssh-server openssh-clients postfix ``` **2. 启动ssh服务&设置为开机启动** ```shell systemctl enable sshd && sudo systemctl start sshd ``` **3. 设置postfix开机自启,并启动postfix支持gitlab发信功能** ```shell systemctl enable postfix && systemctl start postfix ``` **4. 开放ssh以及http服务,然后重新加载防火墙列表** 如果关闭防火墙就不需要做该配置。 ```shell firewall-cmd --add-service=ssh --permanent firewall-cmd --add-service=http --permanent firewall-cmd --reload ``` **5. 下载gitlab包,并且安装** 软件源地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/ 注意:centos7只能安装el6,或者el7的gitlab。 ```shell wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm --no-check-certificate rpm -i gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm ``` **6. 修改gitlab配置** ```shell vim /etc/gitlab/gitlab.rb # 修改gitlab访问地址和端口,默认为80,我们改为82 external_url 'http://192.168.1.22:82' nginx['listen_port'] = 82 ``` **7. 重载配置及启动gitlab** ```shell gitlab-ctl reconfigure gitlab-ctl restart ``` **8. 获取初始密码** ```shell --重载配置后控制台会打印如下信息 Username: root 管理员账号 Password: You didn't opt-in to print initial root password to STDOUT. Password stored to /etc/gitlab/initial_root_password. 初始密码所在文件 --拿到初始密码 cat /etc/gitlab/initial_root_password Password: 7UgjZYA9VYEbGzp83FZdAbw/7RwxZuy7rGpIKQ08H9w= ``` **9. 把端口添加到防火墙** ```shell firewall-cmd --zone=public --add-port=82/tcp --permanent firewall-cmd --reload ``` **10. 访问gitlab:http://192.168.1.22:82/** 输入管理员账号`root`,密码`7UgjZYA9VYEbGzp83FZdAbw/7RwxZuy7rGpIKQ08H9w=`,登录即可。 ![](images/jenkins8.jpg) **11. 修改管理员账号密码** 默认的管理员账号密码24小时后会失效,需要自己重置。 访问:http://192.168.1.22:82/admin/users/root/edit 页面修改账号`root`的密码。 <br/> # 2. Gitlab添加组、创建用户、创建项目 **1. Gitlab添加组—itheima_group** 使用管理员 `root` 创建组,一个组里面可以有多个项目分支,可以将开发添加到组里面进行设置权限,不同的组就是公司不同的开发项目或者服务模块,不同的组添加不同的开发即可实现对开发设置权限的管理。 :-: ![](https://img.kancloud.cn/dd/34/dd34a445ecd933b8d680bee377ae36a4_724x307.jpg) **2. 创建用户—zhangsan** :-: ![](https://img.kancloud.cn/19/02/1902aef32bf4c2851149f057009f8ed4_734x324.jpg) 创建好用户后为新增的用户设置密码: ![](https://img.kancloud.cn/3c/d5/3cd5ae1154e0c5013de38d6463550784_1767x618.jpg) **3. 将用户添加到组中** ![](https://img.kancloud.cn/d0/f3/d0f31dc4673d9687e8438274fab0605a_1486x406.jpg) ![](https://img.kancloud.cn/0e/9c/0e9cfffc2a303966cadc83a5643ebfcf_1461x515.jpg) ![](https://img.kancloud.cn/b2/74/b2741caaa5499edf1ecea075b96c343d_1505x437.jpg) ``` Gitlab用户在组里面有5种不同权限: Guest:可以创建issue、发表评论,不能读写版本库。 Reporter:可以克隆代码,不能提交,QA、PM可以赋予这个权限。 Developer:可以克隆代码、开发、提交、push,普通开发可以赋予这个权限。 Maintainer:可以创建项目、添加tag、保护分支、添加项目成员、编辑项目,核心开发可以赋予这个权限。 Owner:可以设置项目访问权限 - Visibility Level、删除项目、迁移项目、管理组成员,开发组组长可以赋予这个权限。 ``` **4. 在用户组中创建项目** ![](https://img.kancloud.cn/44/b9/44b964936862e941c72eb7eeee3e74a3_1426x293.jpg) <br/>