1 前言
最近在学习 GitLab,将学习成果做个简要总结,以供大家参考。如有错误,欢迎留言纠正!你的「点赞」或「打赏」将是对我最大的支持和鼓励!
- 官网地址:https://about.gitlab.com/
- 在线文档:https://docs.gitlab.com/ce/README.html
- 本地文档:用户登录后,点击右上角 Help 菜单
- 我的版本:GitLab Community Edition 13.3.4
本次系列文章包括:
2 权限与角色
在 GitLab 系统中,项目分为私有项目、内部项目和公开项目三种。用户角色又分非项目成员和项目成员,项目成员还分Guest、Reporter、Developer和Maintainer。细分这么多,对理解权限和角色是有点凌乱的。我总结如下:
非项目成员 | 项目成员 | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
没GitLab账号 | 有GitLab账号 | Guest | Reporter | Developer | Maintainer | |||||||||||||
项目可见 | 代码可见 | 仓库权限 | 项目可见 | 代码可见 | 仓库权限 | 项目可见 | 代码可见 | 仓库权限 | 项目可见 | 代码可见 | 仓库权限 | 项目可见 | 代码可见 | 仓库权限 | 项目可见 | 代码可见 | 仓库权限 | |
私有项目 | × | × | × | × | × | × | √ | × | × | √ | √ | R | √ | √ | R W + C D | √ | √ | R W + C D |
内部项目 | × | × | × | √ | √ | × | √ | √ | R | √ | √ | R | √ | √ | R W + C D | √ | √ | R W + C D |
公开项目 | √ | √ | × | √ | √ | × | √ | √ | R | √ | √ | R | √ | √ | R W + C D | √ | √ | R W + C D |
注意:
- 项目可见:是指在web上能不能看到该项目,有账号的登录后查看项目列表,没账号的直接在 gitlab.example.com/explore 网址查看,其中 gitlab.example.com 是 gitlab 网址,要根据你自己的情况进行修改。
- 代码可见:是指在web上能不能看到该项目的代码。
- 仓库权限:是指git仓库权限,需要特别注意的是,受保护的分支是不允许直接提交的(只能采用merge策略提交),也不允许删除,不允许修改历史。默认情况下 master 分支就是受保护分支。
- 原则上,公司内部管理,是不允许使用“公开项目”。
- 只要有GitLab账号,并且能看到项目,用户就能自己申请加入/退出项目。
- 如果代码不想给“非项目成员”看到,也不让登录的非项目成员看到,可以在「项目 > 设置 > 通用 > 可见性,项目功能,权限 > 仓库」中设置成“仅项目成员”可见。
- RW+CD的意思,代表具有读写,强制覆盖,创建和删除的权限,如果不想让 Developer 具有覆盖和删除的权限,可以将分支设置为 受保护分支。
更多参考:
https://docs.gitlab.com/ce/user/permissions.html
https://www.tutorialspoint.com/gitlab/gitlab_user_permissions.htm
S.N. | Guest | Reporter | Developer | Master |
---|---|---|---|---|
1 | Creates a new issue | Creates a new issue | Creates a new issue | Creates a new issue |
2 | Can leave comments | Can leave comments | Can leave comments | Can leave comments |
3 | Able to write on project wall | Able to write on project wall | Able to write on project wall | Able to write on project wall |
4 | - | Able to pull project code | Able to pull project code | Able to pull project code |
5 | - | Can download project | Can download project | Can download project |
6 | - | Able to write code snippets | Able to write code snippets | Able to write code snippets |
7 | - | - | Create new merge request | Create new merge request |
8 | - | - | Create new branch | Create new branch |
9 | - | - | Push and remove non protected branches | Push and remove non protected branches |
10 | - | - | Includes tags | Includes tags |
11 | - | - | Can create, edit, delete project milestones | Can create, edit, delete project milestones |
12 | - | - | Can create or update commit status | Can create or update commit status |
13 | - | - | Write a wiki | Write a wiki |
14 | - | - | Create new environments | Create new environments |
15 | - | - | Cancel and retry the jobs | Cancel and retry the jobs |
16 | - | - | Updates and removes the registry image | Updates and removes the registry image |
17 | - | - | - | Can add new team members |
18 | - | - | - | Push and remove protected branches |
19 | - | - | - | Can edit the project |
20 | - | - | - | Can manage runners, job triggers and variables |
21 | - | - | - | Add deploy keys to project |
22 | - | - | - | Able to manage clusters |
23 | - | - | - | Configure project hooks |
24 | - | - | - | Can enable/disable the branch protection |
25 | - | - | - | Able to rewrite or remove Git tags |