您好,登錄后才能下訂單哦!
在腳本的同目錄下需要創建一個名為“add-list.txt”的文件,用于存放需要創建的projects,運行時要輸入projects需要加入的指定組的ID,也可以都扔到一個組中,建完projects后直接transfer到相關組。
#/usr/bin/Python27
# coding=utf-8
import gitlab
gl = gitlab.Gitlab('http://10.50.30.33/', private_token='fffghjjjkkllljwj')
gid = int(raw_input('GroupID: ')) #project需要放置的Group的ID
group = gl.groups.get(gid)
print group.name
pid = []
path = 'add-list.txt'
with open(path,'r') as f:
for line in f.readlines():
serv = line.strip()
project = gl.projects.create({'name': serv, 'namespace_id': gid,'path':serv})
branch = project.branches.create({'branch': 'develop','ref': 'master'}) #創建分支1:develop,可以自己修改
branch = project.branches.create({'branch': 'qa_release','ref': 'develop'}) #創建分支2:qa_release,可以自己修改調整
branches = project.branches.list()
print project.name,project.id,branches
pid.append(project.id)
for num in pid:
i = int(num)
project = gl.projects.get(i)
project.default_branch = 'develop' #設置默認分支為develop,可自行修改
project.save()
print project.name,project.http_url_to_repo,project.default_branch
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。