8 files changed
@@ -1,3 +1,6 @@ | |||
| 1 | + python-gitlab | ||
| 2 | + ============= | ||
| 3 | + | ||
| 1 | 4 | .. image:: https://github.com/python-gitlab/python-gitlab/workflows/Test/badge.svg | |
| 2 | 5 | :target: https://github.com/python-gitlab/python-gitlab/actions | |
| 3 | 6 | ||
@@ -19,32 +22,39 @@ | |||
| 19 | 22 | .. image:: https://img.shields.io/badge/code%20style-black-000000.svg | |
| 20 | 23 | :target: https://github.com/python/black | |
| 21 | 24 | ||
| 22 | - Python GitLab | ||
| 23 | - ============= | ||
| 24 | - | ||
| 25 | 25 | ``python-gitlab`` is a Python package providing access to the GitLab server API. | |
| 26 | 26 | ||
| 27 | 27 | It supports the v4 API of GitLab, and provides a CLI tool (``gitlab``). | |
| 28 | 28 | ||
| 29 | 29 | Installation | |
| 30 | - ============ | ||
| 31 | - | ||
| 32 | - Requirements | ||
| 33 | 30 | ------------ | |
| 34 | 31 | ||
| 35 | - python-gitlab depends on: | ||
| 32 | + As of 3.0.0, ``python-gitlab`` is compatible with Python 3.7+. | ||
| 33 | + | ||
| 34 | + Use ``pip`` to install the latest stable version of ``python-gitlab``: | ||
| 35 | + | ||
| 36 | + .. code-block:: console | ||
| 36 | 37 | ||
| 37 | - * `python-requests <https://2.python-requests.org/en/latest/>`_ | ||
| 38 | + $ pip install --upgrade python-gitlab | ||
| 38 | 39 | ||
| 39 | - Install with pip | ||
| 40 | - ---------------- | ||
| 40 | + The current development version is available on both `GitHub.com | ||
| 41 | + <https://github.com/python-gitlab/python-gitlab>`__ and `GitLab.com | ||
| 42 | + <https://gitlab.com/python-gitlab/python-gitlab>`__, and can be | ||
| 43 | + installed directly from the git repository: | ||
| 41 | 44 | ||
| 42 | 45 | .. code-block:: console | |
| 43 | 46 | ||
| 44 | - pip install python-gitlab | ||
| 47 | + $ pip install git+https://github.com/python-gitlab/python-gitlab.git | ||
| 48 | + | ||
| 49 | + From GitLab: | ||
| 50 | + | ||
| 51 | + .. code-block:: console | ||
| 52 | + | ||
| 53 | + $ pip install git+https://gitlab.com/python-gitlab/python-gitlab.git | ||
| 54 | + | ||
| 45 | 55 | ||
| 46 | 56 | Using the docker image | |
| 47 | - ====================== | ||
| 57 | + ---------------------- | ||
| 48 | 58 | ||
| 49 | 59 | You can run the Docker image directly from the GitLab registry: | |
| 50 | 60 | ||
@@ -65,7 +75,7 @@ You can also mount your own config file: | |||
| 65 | 75 | $ docker run -it --rm -v /path/to/python-gitlab.cfg:/etc/python-gitlab.cfg registry.gitlab.com/python-gitlab/python-gitlab:latest <command> ... | |
| 66 | 76 | ||
| 67 | 77 | Building the image | |
| 68 | - ------------------ | ||
| 78 | + ~~~~~~~~~~~~~~~~~~ | ||
| 69 | 79 | ||
| 70 | 80 | To build your own image from this repository, run: | |
| 71 | 81 | ||
@@ -80,32 +90,32 @@ Run your own image: | |||
| 80 | 90 | $ docker run -it --rm -v python-gitlab:latest <command> ... | |
| 81 | 91 | ||
| 82 | 92 | Bug reports | |
| 83 | - =========== | ||
| 93 | + ----------- | ||
| 84 | 94 | ||
| 85 | 95 | Please report bugs and feature requests at | |
| 86 | 96 | https://github.com/python-gitlab/python-gitlab/issues. | |
| 87 | 97 | ||
| 88 | 98 | Gitter Community Chat | |
| 89 | - ===================== | ||
| 99 | + --------------------- | ||
| 90 | 100 | ||
| 91 | 101 | There is a `gitter <https://gitter.im/python-gitlab/Lobby>`_ community chat | |
| 92 | 102 | available at https://gitter.im/python-gitlab/Lobby | |
| 93 | 103 | ||
| 94 | 104 | Documentation | |
| 95 | - ============= | ||
| 105 | + ------------- | ||
| 96 | 106 | ||
| 97 | 107 | The full documentation for CLI and API is available on `readthedocs | |
| 98 | 108 | <http://python-gitlab.readthedocs.org/en/stable/>`_. | |
| 99 | 109 | ||
| 100 | 110 | Build the docs | |
| 101 | - -------------- | ||
| 102 | - You can build the documentation using ``sphinx``:: | ||
| 111 | + ~~~~~~~~~~~~~~ | ||
| 103 | 112 | ||
| 104 | - pip install sphinx | ||
| 105 | - python setup.py build_sphinx | ||
| 113 | + We use ``tox`` to manage our environment and build the documentation:: | ||
| 106 | 114 | ||
| 115 | + pip install tox | ||
| 116 | + tox -e docs | ||
| 107 | 117 | ||
| 108 | 118 | Contributing | |
| 109 | - ============ | ||
| 119 | + ------------ | ||
| 110 | 120 | ||
| 111 | 121 | For guidelines for contributing to ``python-gitlab``, refer to `CONTRIBUTING.rst <https://github.com/python-gitlab/python-gitlab/blob/main/CONTRIBUTING.rst>`_. | |
@@ -0,0 +1,168 @@ | |||
| 1 | + ############ | ||
| 2 | + CLI examples | ||
| 3 | + ############ | ||
| 4 | + | ||
| 5 | + **Notice:** | ||
| 6 | + | ||
| 7 | + For a complete list of objects and actions available, see :doc:`/cli-objects`. | ||
| 8 | + | ||
| 9 | + List the projects (paginated): | ||
| 10 | + | ||
| 11 | + .. code-block:: console | ||
| 12 | + | ||
| 13 | + $ gitlab project list | ||
| 14 | + | ||
| 15 | + List all the projects: | ||
| 16 | + | ||
| 17 | + .. code-block:: console | ||
| 18 | + | ||
| 19 | + $ gitlab project list --all | ||
| 20 | + | ||
| 21 | + List all projects of a group: | ||
| 22 | + | ||
| 23 | + .. code-block:: console | ||
| 24 | + | ||
| 25 | + $ gitlab group-project list --all --group-id 1 | ||
| 26 | + | ||
| 27 | + List all projects of a group and its subgroups: | ||
| 28 | + | ||
| 29 | + .. code-block:: console | ||
| 30 | + | ||
| 31 | + $ gitlab group-project list --all --include-subgroups true --group-id 1 | ||
| 32 | + | ||
| 33 | + Limit to 5 items per request, display the 1st page only | ||
| 34 | + | ||
| 35 | + .. code-block:: console | ||
| 36 | + | ||
| 37 | + $ gitlab project list --page 1 --per-page 5 | ||
| 38 | + | ||
| 39 | + Get a specific project (id 2): | ||
| 40 | + | ||
| 41 | + .. code-block:: console | ||
| 42 | + | ||
| 43 | + $ gitlab project get --id 2 | ||
| 44 | + | ||
| 45 | + Get a specific user by id: | ||
| 46 | + | ||
| 47 | + .. code-block:: console | ||
| 48 | + | ||
| 49 | + $ gitlab user get --id 3 | ||
| 50 | + | ||
| 51 | + Create a deploy token for a project: | ||
| 52 | + | ||
| 53 | + .. code-block:: console | ||
| 54 | + | ||
| 55 | + $ gitlab -v project-deploy-token create --project-id 2 \ | ||
| 56 | + --name bar --username root --expires-at "2021-09-09" --scopes "read_repository" | ||
| 57 | + | ||
| 58 | + List deploy tokens for a group: | ||
| 59 | + | ||
| 60 | + .. code-block:: console | ||
| 61 | + | ||
| 62 | + $ gitlab -v group-deploy-token list --group-id 3 | ||
| 63 | + | ||
| 64 | + List packages for a project: | ||
| 65 | + | ||
| 66 | + .. code-block:: console | ||
| 67 | + | ||
| 68 | + $ gitlab -v project-package list --project-id 3 | ||
| 69 | + | ||
| 70 | + List packages for a group: | ||
| 71 | + | ||
| 72 | + .. code-block:: console | ||
| 73 | + | ||
| 74 | + $ gitlab -v group-package list --group-id 3 | ||
| 75 | + | ||
| 76 | + Get a specific project package by id: | ||
| 77 | + | ||
| 78 | + .. code-block:: console | ||
| 79 | + | ||
| 80 | + $ gitlab -v project-package get --id 1 --project-id 3 | ||
| 81 | + | ||
| 82 | + Delete a specific project package by id: | ||
| 83 | + | ||
| 84 | + .. code-block:: console | ||
| 85 | + | ||
| 86 | + $ gitlab -v project-package delete --id 1 --project-id 3 | ||
| 87 | + | ||
| 88 | + Upload a generic package to a project: | ||
| 89 | + | ||
| 90 | + .. code-block:: console | ||
| 91 | + | ||
| 92 | + $ gitlab generic-package upload --project-id 1 --package-name hello-world \ | ||
| 93 | + --package-version v1.0.0 --file-name hello.tar.gz --path /path/to/hello.tar.gz | ||
| 94 | + | ||
| 95 | + Download a project's generic package: | ||
| 96 | + | ||
| 97 | + .. code-block:: console | ||
| 98 | + | ||
| 99 | + $ gitlab generic-package download --project-id 1 --package-name hello-world \ | ||
| 100 | + --package-version v1.0.0 --file-name hello.tar.gz > /path/to/hello.tar.gz | ||
| 101 | + | ||
| 102 | + Get a list of issues for this project: | ||
| 103 | + | ||
| 104 | + .. code-block:: console | ||
| 105 | + | ||
| 106 | + $ gitlab project-issue list --project-id 2 | ||
| 107 | + | ||
| 108 | + Delete a snippet (id 3): | ||
| 109 | + | ||
| 110 | + .. code-block:: console | ||
| 111 | + | ||
| 112 | + $ gitlab project-snippet delete --id 3 --project-id 2 | ||
| 113 | + | ||
| 114 | + Update a snippet: | ||
| 115 | + | ||
| 116 | + .. code-block:: console | ||
| 117 | + | ||
| 118 | + $ gitlab project-snippet update --id 4 --project-id 2 \ | ||
| 119 | + --code "My New Code" | ||
| 120 | + | ||
| 121 | + Create a snippet: | ||
| 122 | + | ||
| 123 | + .. code-block:: console | ||
| 124 | + | ||
| 125 | + $ gitlab project-snippet create --project-id 2 | ||
| 126 | + Impossible to create object (Missing attribute(s): title, file-name, code) | ||
| 127 | + $ # oops, let's add the attributes: | ||
| 128 | + $ gitlab project-snippet create --project-id 2 --title "the title" \ | ||
| 129 | + --file-name "the name" --code "the code" | ||
| 130 | + | ||
| 131 | + Get a specific project commit by its SHA id: | ||
| 132 | + | ||
| 133 | + .. code-block:: console | ||
| 134 | + | ||
| 135 | + $ gitlab project-commit get --project-id 2 --id a43290c | ||
| 136 | + | ||
| 137 | + Get the signature (e.g. GPG or x509) of a signed commit: | ||
| 138 | + | ||
| 139 | + .. code-block:: console | ||
| 140 | + | ||
| 141 | + $ gitlab project-commit signature --project-id 2 --id a43290c | ||
| 142 | + | ||
| 143 | + Define the status of a commit (as would be done from a CI tool for example): | ||
| 144 | + | ||
| 145 | + .. code-block:: console | ||
| 146 | + | ||
| 147 | + $ gitlab project-commit-status create --project-id 2 \ | ||
| 148 | + --commit-id a43290c --state success --name ci/jenkins \ | ||
| 149 | + --target-url http://server/build/123 \ | ||
| 150 | + --description "Jenkins build succeeded" | ||
| 151 | + | ||
| 152 | + Download the artifacts zip archive of a job: | ||
| 153 | + | ||
| 154 | + .. code-block:: console | ||
| 155 | + | ||
| 156 | + $ gitlab project-job artifacts --id 10 --project-id 1 > artifacts.zip | ||
| 157 | + | ||
| 158 | + Use sudo to act as another user (admin only): | ||
| 159 | + | ||
| 160 | + .. code-block:: console | ||
| 161 | + | ||
| 162 | + $ gitlab project create --name user_project1 --sudo username | ||
| 163 | + | ||
| 164 | + List values are comma-separated: | ||
| 165 | + | ||
| 166 | + .. code-block:: console | ||
| 167 | + | ||
| 168 | + $ gitlab issue list --labels foo,bar | ||
0 commit comments