【问题标题】:REST API to create multiple groups in gitlab at onceREST API 一次在 gitlab 中创建多个组
【发布时间】:2019-05-08 14:06:30
【问题描述】:

我已经安装了 GitLab EE (11.4.7-ee)。我正在尝试使用 REST API 创建多个组。

https://testserver/gitlab/api/v4/groups

发布数据:

[
    { "name": "test1", "path": "test1" },
    { "name": "test2", "path": "test2" },
    { "name": "test3", "path": "test3" }
    ]

错误信息:

{ "error": "name is missing, path is missing" }

如何在一个 GitLab 组中创建多个组创建 Rest API

【问题讨论】:

    标签: gitlab-api gitlab-ee


    【解决方案1】:

    我已经编写了 python 脚本来在 gitlab 中创建多个组

    import requests
    import json
    import urllib3
    
    with open('./jfmjson.json', 'r') as f:
        jfm_dict = json.load(f)
    
    for jfm in jfm_dict:
        print(jfm['path'])
        gitlab_url = "https://testserver/gitlab/api/v4/groups"
        headers = {'Content-type': 'application/json', 'PRIVATE-TOKEN': 'pxpR3sehJ-xYzz61XxAs'}
        data = {'name': jfm['path'], 'path': jfm['path'], 'description': jfm['name']}
        urllib3.disable_warnings()
        r = requests.post(gitlab_url, data=json.dumps(data), headers=headers, verify=False)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-13
      • 2014-09-06
      • 1970-01-01
      • 2021-12-04
      • 2019-09-02
      • 2014-11-16
      相关资源
      最近更新 更多