python-gitlab | A python wrapper for the GitLab API | REST library

 by   python-gitlab Python Version: 4.4.0 License: LGPL-3.0

kandi X-RAY | python-gitlab Summary

kandi X-RAY | python-gitlab Summary

python-gitlab is a Python library typically used in Web Services, REST applications. python-gitlab has no bugs, it has no vulnerabilities, it has build file available, it has a Weak Copyleft License and it has high support. You can install using 'pip install python-gitlab' or download it from GitHub, GitLab, PyPI.

A python wrapper for the GitLab API.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              python-gitlab has a highly active ecosystem.
              It has 2015 star(s) with 629 fork(s). There are 49 watchers for this library.
              There were 6 major release(s) in the last 6 months.
              There are 83 open issues and 1079 have been closed. On average issues are closed in 80 days. There are 27 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of python-gitlab is 4.4.0

            kandi-Quality Quality

              python-gitlab has 0 bugs and 0 code smells.

            kandi-Security Security

              python-gitlab has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              python-gitlab code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              python-gitlab is licensed under the LGPL-3.0 License. This license is Weak Copyleft.
              Weak Copyleft licenses have some restrictions, but you can use them in commercial projects.

            kandi-Reuse Reuse

              python-gitlab releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.

            Top functions reviewed by kandi - BETA

            kandi has reviewed python-gitlab and discovered the below as its top functions. This is intended to give you an instant insight into python-gitlab implemented functionality, and help decide if they suit your requirements.
            • Create a new package
            • Build the url
            • Make a HTTP request
            • Make a HTTP PUT request
            • Parses the config file
            • Decode the message
            • Gets values from helper
            • Create a Gitlab instance
            • Merge auth options
            • Create a new commit status
            • Get an object by id
            • Extend argument parser
            • Return an argument parser
            • Share a group
            • Download files from Gitlab
            • Get the content of the object
            • Merge this branch
            • Get the content of the snippet
            • Set a feature
            • Upload a file
            • Get the raw artifact at the given path
            • Download a file from Gitlab
            • Returns a list of configuration files
            • Get the status of the object
            • Get the contents of the artifact
            • Update an object
            Get all kandi verified functions for this library.

            python-gitlab Key Features

            No Key Features are available at this moment for python-gitlab.

            python-gitlab Examples and Code Snippets

            Python Interface
            Shelldot img1Lines of Code : 36dot img1no licencesLicense : No License
            copy iconCopy
            import gitlab
            
            gl = gitlab.Gitlab.from_config()
            
            # list all users.
            for user in gl.users.list(all=True):
                print(f'{user.id}\t{user.name}\t{user.email}')
            
            # list all groups and projects.
            for group in gl.groups.list(all=True):
                print(f'{group.id}\  
            Gitlabracadabra ,Using gitlabracadabra in GitLab CI
            Pythondot img2Lines of Code : 32dot img2License : Weak Copyleft (GNU LGPLv3)
            copy iconCopy
            default:
              image:
                name: registry.gitlab.com/gitlabracadabra/gitlabracadabra:v1.2.0
                entrypoint: [""]
              before_script:
                - |
                    cat << EOF > ~/.python-gitlab.cfg
                    [global]
                    default = gitlab
                    [gitlab]
                     
            Gitlabracadabra ,Configuration
            Pythondot img3Lines of Code : 6dot img3License : Weak Copyleft (GNU LGPLv3)
            copy iconCopy
            [global]
            default = gitlab
            
            [gitlab]
            url = https://gitlab.com
            private_token = T0K3N
              

            Community Discussions

            QUESTION

            python-gitlab - how to modify project settings?
            Asked 2022-Mar-09 at 12:34

            I'm writing a python module to create projects in gitlab, but I can't figure out how to change the default project settings, like remove_source_branch_after_merge.

            I've tried passing the argument to the projects.create() call, but it seems to be ignored.

            ...

            ANSWER

            Answered 2022-Mar-09 at 12:34

            To answer your question, modifying attributes after an object has been created can be done with save():

            Source https://stackoverflow.com/questions/71408832

            QUESTION

            How to create a new branch, push a text file and send merge request to a gitlab repository using Python?
            Asked 2021-Dec-16 at 04:42

            I found https://github.com/python-gitlab/python-gitlab, but I was unable to understand the examples in the doc.

            ...

            ANSWER

            Answered 2021-Dec-15 at 17:58

            Looking at python-gitlab, I don't see some of the things you are looking for. In that case, I suggest you break it apart and do the individual steps using more basic tools and libraries.

            The first two parts you don't need to use Gitlab API to do. You can basically use Python to do the clone, branch, edit, and commit calls using git.exe and against your disk. In some ways, that is easier since you can duplicate the calls yourself. You could use GitPython.

            I'd recommend you do that through one of these methods instead of trying to do it via Gitlab API. It's easier to understand, debug, and investigate if you do the branch work locally (or even inside a CI).

            Once you push up the code into a branch, you can use Gitlab's API to create a merge request via REST (such as the requests library). The description for creating the MR is at https://docs.gitlab.com/ee/api/merge_requests.html#create-mr and most of the fields are optional so the minimum looks like:

            Source https://stackoverflow.com/questions/70367905

            QUESTION

            Python GitLab - Getting artifacts result in list error
            Asked 2021-Nov-14 at 07:46

            I try to download build artifacts from a CI/CD pipeline by using the GitLab API for Python. I took a look at the documentation and wrote the following example:

            ...

            ANSWER

            Answered 2021-Nov-13 at 21:26

            The distinction here is subtle. Using pipeline.jobs.list doesn't use the same underlying API as project.jobs.list (or .get)

            In terms of the Python-Gitlab library, when you do pipeline.jobs.list() you get a list of gitlab.v4.objects.ProjectPipelineJob objects. The .artifacts attribute of this type of object is not a method -- it's an a list containing information about the artifacts, like file type, size file name, etc -- which is what you're seeing in your image.

            This is different from a gitlab.v4.objects.ProjectJob object, which is what is shown in the documentation. You obtain this kind of object from project.jobs.get or project.jobs.list.

            So, to correct this error you can edit the tail end of your code as follows:

            Source https://stackoverflow.com/questions/69948631

            QUESTION

            GitlabParsingError when accessing a project with GitLab API with Python
            Asked 2021-Nov-07 at 00:40

            I try to access a project on a private GitLab instance (please take a look at the screenshot for the version numbers) by using the python-gitlab module.

            I have created an access token with all permissions over the web UI of the GitLab repository and copied this token into my Python code:

            ...

            ANSWER

            Answered 2021-Nov-07 at 00:40

            The first argument to gitlab.Gitlab() is the base URL of the instance not the full path to your project. e.g. https://gitlab.example.com. You should also use the keyword private_token

            So, unless your instance lives at a relative path, you should have:

            Source https://stackoverflow.com/questions/69862881

            QUESTION

            Upload binary files using python-gitlab API
            Asked 2021-Nov-03 at 18:47

            I'm tasked with migrating repos to gitlab and I decided to automate the process using python-gitlab. Everything works fine except for binary or considered-binary files like compiled object files ( .o ) or .zip files. (I know that repositories are not place for binaries. I work with what I got and what I'm told to do.)

            I'm able to upload them using:

            ...

            ANSWER

            Answered 2021-Nov-03 at 18:46

            The problem is that Python's base64.b64encode function will provide you with a bytes object, but REST APIs (specifically, JSON serialization) want strings. Also the argument you want is encoding not encode.

            Here's the full example to use:

            Source https://stackoverflow.com/questions/69829411

            QUESTION

            How to programmatically access the full snippet in Gitlab?
            Asked 2021-Nov-03 at 12:11
            Question

            My end goal is to have an offline, updateable copy of my snippets (including title & description) such that I can search and use them easily. How can I get all my snippets from Gitlab to my local machine? I'm using Gitlab version is 13.12.10-ee.

            What I've looked into Cloning snippets

            It's possible to clone snippet contents in Gitlab, but this only includes the file associated with the snippet. The title and description are excluded.

            E.g. when I do git clone git@company.gitlab.com:snippets/$snippet_id.git I only receive the files associated with the snippet, not the title and the description:

            I've checked the documentation but could not find any mention of interacting with the description through git.

            Gitlab API

            I found that the Gitlab API has a snippets endpoint. However, when I use the python-gitlab CLI tool and request a single snippet with gitlab snippet get --id 123 I only get the ID and the title.
            When I do gitlab snippet content --id 123 I only get the contents of the file associated with the snippet.

            ...

            ANSWER

            Answered 2021-Oct-25 at 22:32
            From a Unix shell, using CuRL and jq:

            Source https://stackoverflow.com/questions/69660547

            QUESTION

            AWS Lambda function does not recognize my Python dependency layer
            Asked 2021-Sep-13 at 22:36

            My goal is to upload a small layer for an aws lambda function using the python 3.7 runtime that stores python dependencies, but I cannot seem to get it to recognize the modules.

            I created a Makefile to generate the zip file

            ...

            ANSWER

            Answered 2021-Sep-09 at 21:59

            I had this SAME problem and it took me a week to solve. I think this answer can help you: Import libraries in lambda layers

            Here is the key stuff:

            You want to make sure your .zip follows this folder structure when unzipped

            python/lib/python3.6/site-packages/{LibrariesGoHere}.

            Upload that zip, make sure the layer is added to the Lambda function and you should be good to go.

            Also, I think your question would get better attention if you update your tag to "aws-lambda-layers"

            Source https://stackoverflow.com/questions/69125055

            QUESTION

            Python Gitlab API invite group to project
            Asked 2021-Jul-28 at 17:01

            I'm trying to add a gitlab group to a project after the project is created. I can see in the Gitlab API documentation that it's possible to invite a MEMBER to a group to or a project (https://docs.gitlab.com/ee/api/invitations.html)

            It's however possible to invite a group to a project from the Gitlab Dashboard when navigating the Members menu, under Project information.

            How would I go about adding a group to a project after it is created using the python-gitlab API?

            ...

            ANSWER

            Answered 2021-Jul-28 at 17:01

            I found the solution at https://python-gitlab.readthedocs.io/en/stable/gl_objects/projects.html#project-members

            It is important to note the Gitlab have two types for projects as stated in https://python-gitlab.readthedocs.io/en/stable/gl_objects/groups.html#group-members

            GroupProject objects returned by this API call are very limited, and do not provide all the features of Project objects. If you need to manipulate projects, create a new Project object:

            Source https://stackoverflow.com/questions/68563151

            QUESTION

            Gitlab: Get ancestor groups of a project via Python API bindings
            Asked 2021-Jun-22 at 16:57

            Im using https://github.com/python-gitlab/python-gitlab to automate several tasks over multiple Gitlab repositories / projects. This worked fine up until now: I have a Gitlab project and want to get its parent group. According to https://docs.gitlab.com/13.12/ee/api/projects.html#list-a-projects-groups this should be possible, but I cannot find that functionality in the Python bindings.

            Am I missing something? Is that feature missing in the Python bindings? Does anybody know a workaround, that does not force me to got to "pure" REST?

            ...

            ANSWER

            Answered 2021-Jun-22 at 16:57

            After reading the code it looks like the feature is just missing, but I figured out a workaround:

            Source https://stackoverflow.com/questions/68085749

            QUESTION

            Retrieving project coverage with python-gitlab
            Asked 2021-Jun-07 at 08:48

            I use the python-gitlab module to retrieve the project statistics for a number of projects in Gitlab via its API. One of the values I want to get is the CI status and the code coverage. While the status is easy:

            ...

            ANSWER

            Answered 2021-Jun-07 at 08:48

            This is in the pipeline object:

            Source https://stackoverflow.com/questions/67867768

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install python-gitlab

            You can install using 'pip install python-gitlab' or download it from GitHub, GitLab, PyPI.
            You can use python-gitlab like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install python-gitlab

          • CLONE
          • HTTPS

            https://github.com/python-gitlab/python-gitlab.git

          • CLI

            gh repo clone python-gitlab/python-gitlab

          • sshUrl

            git@github.com:python-gitlab/python-gitlab.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link