问:今天聊的GitLab 是个什么东西呢?

答:比如你的app要升级,v1、v2有两份代码 ,gitlab就可以分别存储着两份。

GitLab 是什么?

 

如果听说过 Git 或者 GitHub,那么 GitLab 你一定也听说过。GitLab 是一个用于仓库管理系统的开源项目,使用 Git 作为代码管理工具,并在此基础上搭建起来的 Web 服务。简单理解:GitLab 类似私人版 Github。

docker 安装 GitLab

 

  • 查询 GitLab 版本的访问地址:https://registry.hub.docker.com/r/gitlab/gitlab-ce/tags

 

  • 拉取 docker 镜像docker pull gitlab/gitlab-ce:latest

 

  • 运行镜像docker run -d -p 443:443 -p 80:80 -p 222:22 --name gitlab --restart always gitlab/gitlab-ce80端口:gitlab网址端口222端口:ssh端口

 

  • GitLab 能正常访问,但是 clone 地址不正确

sourceTree连不上gitLab_软件测试

 

  • 这里 4fa3da313a30 是 GitLab 容器的 id 值。

sourceTree连不上gitLab_接口测试_02

 

  • 修改容器 IP

1. 因为没有挂载目录,直接进入容器内容

docker exec -it gitlab /bin/bash

 

2. 修改gitlab.rb

vi /etc/gitlab/gitlab.rb

 

3. 新增内容 gitlab.rb本来是空文件,在非注释位置加入下面3行代码,IP和端口根据实际情况修改。

external_url 'http://192.168.232.128'

gitlab_rails['gitlab_ssh_host'] = '192.168.232.128'

gitlab_rails['gitlab_shell_ssh_port'] = 222

 

4. 重启容器

docker restart gitlab

  • clone 地址显示正常 IP

sourceTree连不上gitLab_软件测试_03

 

 idea 集成 GitLab

 

1、安装 GitLab Project 插件

sourceTree连不上gitLab_自动化测试_04

 

安装完毕之后重启 idea。

 

2、设置 GitLab 服务器

sourceTree连不上gitLab_软件测试_05

 

3、添加 token 配置,注意选择 HTTPS 方式

sourceTree连不上gitLab_软件测试_06

 

4、打开 GitLab 生成 token 页面,填写名称、有效时间、范围

sourceTree连不上gitLab_测试工程师_07

 

5、提交项目到 GitLab

sourceTree连不上gitLab_测试工程师_08

 

填写项目名,注意选择 Http 方式

sourceTree连不上gitLab_软件测试_09

 

6、项目提交到 GitLab 成功

sourceTree连不上gitLab_sourceTree连不上gitLab_10

 

7、Git 基本操作

  • 拉取

sourceTree连不上gitLab_测试工程师_11

 

  • 提交

sourceTree连不上gitLab_接口测试_12

 

  • 推送

sourceTree连不上gitLab_接口测试_13