gitlab通過api創建組、項目、成員


前戲

獲取gitlab中admin用戶的private_token

Groups API

獲取某個組的詳細

curl --header "PRIVATE-TOKEN: *********" http://192.168.10.7:8090/api/v4/groups/client   #獲取client組的詳細信息

client組的詳細信息
{ "id" : 6 , "name" : "client" , "path" : "client" , "description" : "客戶端" , "visibility" : "private" , "lfs_enabled" :true, "avatar_url" :null, "web_url" : "http://192.168.10.7:8090/groups/client" , "request_access_enabled" :false, "full_name" : "client" , "full_path" : "client" , "parent_id" :null, "projects" :[], "shared_projects" :[]}

添加一個組

POST /groups

Parameters:

  • name (required) - The name of the group #必須
  • path (required) - The path of the group  #必須
  • description (optional) - The group's description
  • membership_lock (optional, boolean) - Prevent adding new members to project membership within this group
  • share_with_group_lock (optional, boolean) - Prevent sharing a project with another group within this group
  • visibility (optional) - The group's visibility. Can be privateinternal, or public.
  • lfs_enabled (optional) - Enable/disable Large File Storage (LFS) for the projects in this group
  • request_access_enabled (optional) - Allow users to request member access.
  • parent_id (optional) - The parent group id for creating nested group.
  • shared_runners_minutes_limit (optional) - (admin-only) Pipeline minutes quota for this group
 

curl --request POST --header "PRIVATE-TOKEN: *****" --data "name=shanxi&path=shanxi" http://192.168.10.7:8090/api/v4/groups; #添加山西組

添加一個子組

gitlab社區版在9.0以后增加了子組的功能,比如我在shanxi這個組下面添加taiyuan這個子組

curl --request POST --header "PRIVATE-TOKEN: ******" --data "name=taiyuan&path=taiyuan&parent_id=父組的id" http://192.168.10.7:8090/api/v4/groups;

User API

添加一個用戶

curl  -d "password=$password&email=$mail&username=$username&name=$name&private_token=************" http://192.168.10.7:8090/api/v4/users

Projects API

添加一個項目

加入shanxi組的id是4,我想在shanxi組下面創建一個majiang項目

curl --request POST --header "PRIVATE-TOKEN: *********" --data "name=majiang&namespace_id=4" http://192.168.10.7:8090/api/v4/projects

 

詳細文檔猛戳

https://docs.gitlab.com/ee/api/README.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM