Gitlab權(quán)限管理
Gitlab權(quán)限管理
Gitlab用戶在組中有五種權(quán)限:
Guest胆描、Reporter、Developer仗阅、Master昌讲、Owner
- Guest:可以創(chuàng)建issue、發(fā)表評(píng)論减噪,不能讀寫版本庫(kù)
- Reporter:可以克隆代碼短绸,不能提交,QA筹裕、PM可以賦予這個(gè)權(quán)限
- Developer:可以克隆代碼醋闭、開(kāi)發(fā)、提交朝卒、push证逻,RD可以賦予這個(gè)權(quán)限
- Master:可以創(chuàng)建項(xiàng)目、添加tag抗斤、保護(hù)分支囚企、添加項(xiàng)目成員、編輯項(xiàng)目瑞眼,核心RD負(fù)責(zé)人可以賦予這個(gè)權(quán)限
- Owner:可以設(shè)置項(xiàng)目訪問(wèn)權(quán)限 - Visibility Level龙宏、刪除項(xiàng)目、遷移項(xiàng)目负拟、管理組成員烦衣,開(kāi)發(fā)組leader可以賦予這個(gè)權(quán)限
Gitlab中的組和項(xiàng)目有三種訪問(wèn)權(quán)限:Private、Internal掩浙、Public
Visibility Level
- Private:只有組成員才能看到
- Internal:只要登錄的用戶就能看到
- Public:所有人都能看到
開(kāi)源項(xiàng)目和組設(shè)置的是Internal
批量導(dǎo)出所有項(xiàng)目
# -*- coding: UTF-8 -*-
# 在Python3.0測(cè)試通過(guò)
# 需要在gitlab里面新建一個(gè)AccessToken填入gitlabToken
import sys
if sys.version_info < (3, 0):
import urllib
else:
from urllib.request import urlopen
import json
import subprocess, shlex
import time
import os
gitlabAddr = '192.168.20.15:9222'
# gitlabToken獲取
gitlabToken = 'G2FQENzmN_fjPF2RAJtb'
for index in range(10):
url= "http://%s/api/v4/projects?private_token=%s&per_page=100&page=%d&order_by=name" % (gitlabAddr, gitlabToken, index)
print(url)
if sys.version_info < (3, 0):
allProjects = urllib.urlopen(url)
else:
allProjects = urlopen(url)
allProjectsDict = json.loads(allProjects.read().decode(encoding='UTF-8'))
if len(allProjectsDict) == 0:
break
for thisProject in allProjectsDict:
try:
thisProjectURL = thisProject['http_url_to_repo']
thisProjectPath = thisProject['path_with_namespace']
print(thisProjectURL + ' ' + thisProjectPath)
if os.path.exists(thisProjectPath):
command = shlex.split('git -C "%s" pull' % (thisProjectPath))
else:
command = shlex.split('git clone %s %s' % (thisProjectURL, thisProjectPath))
resultCode = subprocess.Popen(command)
time.sleep(0.5)
except Exception as e:
print("Error on %s: %s" % (thisProjectURL, e.strerror))