Python export gitlab project
- install python-gitlab module
pip install python-gitlab python3 pip3 install python-gitlab
- gitlab application API access token
path User Settings -> Access Tokens - configure pythongitlab.cfg and place
in the same directory
[global] default = username ssh_verify = False timeout = 8 [username] url = https://gitlab.com private_token = xxxxxxxxxxxx
对于API v4使用url https://gitlab.com,如果您使用API v3使用url
https://gitlab.example.com</引用>
李- <>
import gitlab
gl = gitlab.Gitlab.from_config('username', ['python-gitlab.cfg'])
projects = gl.projects.list()
print(projects)
- or use the following code to get the group project
import gitlab class GitlabAPI(object): def __init__(self, *args, **kwargs): self.gl = gitlab.Gitlab('https://gitlab.com', private_token='xxxxxxxxxxxxx', api_version='4') # 可行 先获取所有group ID, 然后根据group ID 获取项目地址 def get_all_group(self): return self.gl.groups.list(all=True) def get_group_by_id(self, groupID): group = self.gl.groups.get(groupID) projects = group.projects.list(all=True) result_list = [] for project in projects: result_list.append(project.http_url_to_repo) return result_list apiObject = GitlabAPI() groupProjects = apiObject.get_group_by_id(填写获取到的groupID) print(groupProjects)
Read More:
- [Solved] Python Project Import Module Error: ModuleNotFoundError
- [Solved] pychar Submit gitlab Error: LF would be replaced by CRLF
- [Solved] pycharm Import New Project Error: cannot set up a python sdk
- Python3 Error: Cannot uninstall ‘numpy’. It is a distutils installed project and thus we cannot accurate
- [Solved] Python project runs the open() function error: FileNotFoundError: [Errno 2] No such file or directory
- [Solved] Python Project Error: django.core.exceptions.ImproperlyConfigured: WSGI application ‘WebTool.wsgi.application
- Python automatically generates the requirements file for the current project
- Invalid python sd, Fatal Python error: init_fs_encoding: failed to get the Python cod [How to Solve]
- [Solved] NPM install Error: check python checking for Python executable python2 in the PATH
- How to Solve Python WARNING: Ignoring invalid distribution -ip (e:\python\python_dowmload\lib\site-packages)
- [Solved] opencv-python: recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all‘ failed
- Python Error: pip install mysql-connector-python failed
- [Solved] supervisor Error: /usr/local/lib/python2.7/dist-packages/pkg_resources/py2_warn.py:22: UserWarning: Setuptools will stop working on Python 2
- npm install Error: stack Error: Can’t find Python executable “python”
- Linux installs Python and upgrades Python
- Opencv-python Install is Stuck Error: running setup.py bdist_wheel for opencv-python
- Pychar can’t connect to Python console, but it can run. Py file, and Anaconda’s command line can run Python command
- [Solved] cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\……
- [Solved] Python Error: tensorflow.python.framework.errors_impl.UnknownError: 2 root error(s) found.
- Python 3 uses the relative path import module