'Gitlab-Python - Using the API to fork a existing group into a created subgrou
As an automated event, and having had a client artifact subgroup created, using the Gitlab API, I want for fork a existing repo into the newly created subgroup.
Example Repo: Exists (Fork_repo_ID)
Destination: the previously created subgroup
Goal Through an automation event, and having had a client artifact subgroup created, a repo is forked and the new repo is placed in the proper client subgroup.
I'm going to use the Gitlab-python API to demo this by cmd in python - as far as the forking goes I'm having trouble finding examples. I have a static project_id to pull the fork from but I'm not sure how to path it to the newest subgroup/at all really. I've found the following for the API
project = gl.projects.get(fork_project_id)
fork = project.forks.create({'namespace': subgroup.path})
Does anyone have any reference for this/pathing it the correct way? I'd really appreciate it!
Solution 1:[1]
What you have will work, but using namespace is deprecated. Use namespace_id or namespace_path instead:
project.forks.create({'namespace_id': subgroup.id})
Remember, the python-gitlab library is just a wrapper around the official GitLab API. You can reference the projects API fork endpoint (or API documentation for any other endpoint) for an up-to-date and complete reference.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sytech |
