75 questions
1
vote
0
answers
66
views
python-gitlab & curl - Impossible to configure proxy
I have a problem !
I work on gitlab UI on python.
I try to connect to gitlab like this:
import requests
import gitlab
GITLAB_URL = 'MY_GITLAB_URL'
PERSONAL_TOKEN = 'MY_PERSONAL_TOKEN'
PROXIES = {&...
0
votes
0
answers
328
views
Using the Gitlab API in Python, how do I retrieve a file from a specific commit
For a project I am trying to retrieve every commit and for each updated file, I want to store the entire file (without the commit syntax, just the vanilla file) and which lines were updated. I am ...
1
vote
1
answer
334
views
add a comment to an existing issue in gitlab
with that code I can create an issue in GitLab with python-gitlab
issue = project.issues.create({'title': title, 'description': description})
issue.labels = ['label1', 'label2']
issue....
0
votes
1
answer
256
views
AttibuteError when trying to get personal_access_token when using python-gitlab library
I'm trying to perform a basic task of getting the logged in users GitLab personal access token using the python-gitlab library. The documentation here is what I am using in the code below - https://...
0
votes
1
answer
453
views
How to update a Branch using python-gitlab for Gitlab API?
Im working on a small project which uses python-gitlab on its version 3.13.0
The project has a mixture of 2.x.x and 3.x.x features that i've been fixing, but there are a few methods for branches that ...
1
vote
1
answer
220
views
How to get the projects url by project id by using gitlab library in python
I'm writing some script for gitlab and i wanna get urls of projects in gitlab by using only project ID
so i read all docs about library python-gitlab but couldn't find some attributes for it.
this is ...
0
votes
1
answer
391
views
Python Gitlab's creating commit functionality doesn't work if the file is renamed
I have a source repository in gitlab and by forking that I've created destination repository. Now if in the source repository new commits are pushed I want to copy those commits in the destination ...
0
votes
1
answer
185
views
403 Forbidden error when I tried to assign a user developer role using GitLab API through Python code
I have written a Python program using FastAPI and the python-gitlab library (https://python-gitlab.readthedocs.io/en/stable/ ) to provide the developer role on the GitLab project repository to the ...
0
votes
1
answer
2k
views
Getting HTTP Error 403 Forbidden when making call to GitLab server using Python code
I have written a small Python code to get the Storage usage of a GitLab repository. However when I run my code then I get this 403 Forbidden error. This repo, say test_repo_1 is under a test_group_1. ...
0
votes
1
answer
310
views
Python_Gitlab How to extract string from the output of ProjectJob.trace API call
I use python-gitlab API call ProjectJob.trace (https://python-gitlab.readthedocs.io/en/stable/api/gitlab.v4.html#gitlab.v4.objects.ProjectJob.trace) to get the log of a GitlabCI pipeline Terraform job....
0
votes
0
answers
30
views
Pushing picture to gitlab with python-gitlab
I am trying to push a jpg picture to a gitlab repo with python-gitlab. My code looks like
gl = gitlab.Gitlab(GITLAB_URL, PRIVATE_TOKEN)
project = gl.projects.get(PROJECT_ID)
with open(file_path, 'rb')...
0
votes
2
answers
464
views
Set should_remove_source_branch to true is not reflected
with python-gitlab I can create and update merge requests in GitLab.
However there is not much documentation on how to tick the "Delete source branch"
I tried with
mr.attributes['...
0
votes
1
answer
1k
views
Attempted to initialize RESTObject with a non-dictionary value when adding file to GitLab project using python-gitlab
I am trying to create GitLab projects through GitLab CI pipeline by importing the GitLab export tar.gz file using python-gitlab library. The new project gets created but does not get initialized with ...
0
votes
1
answer
315
views
Python-gitlab Creating a project in a subgroup
My namespace structure is something like https://gitlab.com/ES/BSK/Projectx
I'm trying to create a project under the BSK subgroup like projectx.
Each time I try to create a project using the attribute ...
0
votes
1
answer
1k
views
How to get discussion threads from merge request using python-gitlab on gitlab?
Using python-gitlab I succeed to retrieve notes from a merge request.
For example, I get:
"1444097483": {"id": 1444097483, "type": "DiffNote", "body":...
0
votes
0
answers
463
views
How can a GitLab issue be promoted to an epic programmatically?
I am supporting a set of teams that have a large number of issues that need to be promoted to epics. I am working on a Python 3 script to do this using python-gitlab v3.14.0. However, i do not see a ...
2
votes
1
answer
411
views
Trouble mocking the return value of python-gitlab method
I am trying to mock the return value of the following method
import gitlab
from unittest.mock import patch
def get_all_iters():
gl = gitlab.Gitlab(url='test_url', private_token)
result = gl....
2
votes
0
answers
236
views
How to check if a file is stored via LFS without downloading its content using python-gitlab?
I have several files stored on my repository. Some are stored via LFS. I want to check that the file I am handling is stored via LFS without downloading it using python-gitlab. Is it possible to do so?...
0
votes
1
answer
968
views
How do I list the tags for a runner using python-gitlab
I know how to get to (some) attributes of runners setup for a gitlab project. I need though to list the tags each runner defines?
Below is as far as I have gone.
gl = gitlab.Gitlab(url=<my-gitlab-...
0
votes
1
answer
532
views
Python Gitlab API - attributes
Using python Gitlab API, how to list merge requests filtered by some attributes ?
For instance, using curl I can use attributes in my request like ?author_username=MY_NAME&source_branch=MY_BRANCH.
...
1
vote
0
answers
716
views
Using Python Gitlab API to search for all public repositories
I want to identify all public repositories in Gitlab with a specific condition. For example, I want to identify all Java projects that has "AndoridManifest.xml" file and contains the word &...
0
votes
1
answer
235
views
How to retrieve the star counts in GitLab Python API?
I try to request the number of stars and commits of a public software repository in GitLab using its Python client. However, I keep getting GitlabHttpError 503 if executing the following script.
...
1
vote
0
answers
652
views
How do I retrieve and save an avatar from a gitlab project using python?
So I'm creating projects and deleting them by python script using the gitlab python API. That part is working. But a colleague started adding some avatars to some of my autoprojects that I found ...
1
vote
1
answer
1k
views
Python Gitlab commit functionality works from main but the same thing doesn't work when put into a function
I have been trying to make a git commit using gitlab python module and this code works fine when executed from main -
private_token = "xxxxxx"
gl = gitlab.Gitlab('https://gitlab.xyz.net/', ...
0
votes
1
answer
2k
views
Add a file in Gitlab project repository by Python
I have a python script where I have created an output file as an excel table. Now I would like to add/upload this file to my Gitlab project repository directly by using python-gitlab library. I have ...
2
votes
1
answer
2k
views
Gitlab v4 api 403 forbidden error for project.variables.list(get_all=True)
I am using Gitlab v4 api to list a project's variables, while the code returns vars for some projects, it also returns 403 forbidden response for some other projects. And the error is not very verbose ...
0
votes
1
answer
451
views
KeyError: 'releases' when trying to follow the python gitlab API examples
I'm attempting to following the API example here, but it fails because apparently there is no ProjectReleaseManager on my project.
>>> gl.api_version
'4'
>>> gl_project = gl.projects....
0
votes
1
answer
1k
views
Unable to connect to python-gitlab
I am attempting to use python-gitlab to create a script that automates the creation of branches. However, when I try to connect and get a specific group, I get the error:
Exception has occurred: ...
1
vote
1
answer
513
views
Gitlab-Python Api. After creating MR cant get actual MR status info
Im creating MR with python-gitlab. After creation i need to check for mr_conflicts and pipeline state.
project = gl.projects.get(PROJECT_ID, lazy=False)
create_mr = project.mergerequests.create({'id': ...
0
votes
1
answer
2k
views
How to get all users in a project in gitlab through API?
I want to retrieve all members in a project irrespective of their role.
According to this documentation (https://docs.gitlab.com/ee/api/members.html)
If i use this API : GET /projects/:id/members
I ...
0
votes
1
answer
815
views
Dynamically setting git config in python
In my python program, I am trying to dynamically set user credentials - GIT config for GIT.
Repo.config_writer().set_value("user", "name", "username").release()
Repo....
1
vote
1
answer
545
views
Python-GitLab Unprotect master
In the previous version of Python-GitLab after creating the project and adding a user as a developer, we have been using:
# Unprotect master
branch = project.branches.get('master')
branch.unprotect()
...
2
votes
1
answer
2k
views
python-gitlab mocking ProjectCommit objects API V4
I am trying to create a mock object of gitlab.v4.objects.ProjectCommit to perform integration tests between a tool I am developing with python-gitlab api. In order to create a ProjectCommit mock ...
0
votes
2
answers
2k
views
Python Gitlab API find creator of a project
import gitlab
gl = gitlab.Gitlab('http://gitlab.mycompany', private_token=access_token)
gl.auth()
projects = gl.projects.list()
pres = projects[0]
for project in projects:
if 'myprojectname' in ...
1
vote
1
answer
4k
views
Is there a way to get specific jobs by name of the last week with python-gitlab?
What I want to do:
To create reports from gitlab artifacts, I want to look at all recent jobs (the past week or so) with a certain name (lighthouse in my example) and extract all artifacts.
The ...
0
votes
1
answer
1k
views
How can I find out who pushed an image to the Gitlab Container registry
I want to find out who / what user pushed an image to the Gitlab Container registry. Optimally by using the gitlab-python package.
When using the gitlab-python package I was able to get the object '...
1
vote
1
answer
2k
views
python-gitlab - how to modify project settings?
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 ...
0
votes
1
answer
827
views
Get status codes with python-gitlab
Hi does anyone know if there is a way to get http status codes with python-gitlab? Or is there a way to use requests with python-gitlab to get the status codes?
Like how in the requests library you ...
2
votes
1
answer
5k
views
How to get GitLab commits of a file using python gitlab module?
We are trying to get the commits of each file in a Gitlab repository. We are using the Python Gitlab module. We could get the commits of a repository but couldn't get the commits of individual files ...
0
votes
1
answer
770
views
How can I get information from Git about metadata changes over a certain period of time using Git Python?
Need to pull information about metadata changes from the project in the git (there is a local copy), namely: The number of commits per file (code, metadata) for 2 weeks on a certain branch
on the ...
1
vote
1
answer
5k
views
GitLab Python Clone Everything with Structure
I want to clone all of the projects in my GitLab environment. There are a number of groups and subgroups with their own projects. I'd like to clone the projects while maintaining the structure of the ...
0
votes
1
answer
276
views
Python version for curl --output
I have a GitLab API (v4) that I need to call to get a project sub-directory (something apparently new in v.14.4, it seems not yet included python-gitlab libs), which in curl can be done with the ...
1
vote
1
answer
700
views
Get GitLab Issue Service Desk Email via API
I'm creating a separate app for users to visualize GitLab issues without needing access to GitLab. We are using python-gitlab to retrieve the issue data for display on this separate site. Users will ...
0
votes
3
answers
197
views
Python to extract output from attribute
I am trying to extract the specific details like authored_date from the attribute which I am getting with help of python.
What is my end goal:
I want to extract the specific branches which are named ...
0
votes
1
answer
1k
views
Delete Specific branch with Python-Gitlab module
I am extreme beginner in writing python scripts as I am learning it currently.
I am writing a code where I am going to extract the branches which I have which are named something like ...
2
votes
1
answer
3k
views
Upload binary files using python-gitlab API
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 )...
1
vote
4
answers
5k
views
Python Gitlab API - list shared projects of a group/subgroup
I need to find all projects and shared projects within a Gitlab group with subgroups. I managed to list the names of all projects like this:
group = gl.groups.get(11111, lazy=True)
# find all ...
0
votes
1
answer
3k
views
Python Git and Git-Lab create project and push code/commit
We are building an automation process using python in which we clone a base source code repository and add necessary changes to it and add the new code to a new git repository and push it to our ...
1
vote
1
answer
1k
views
How to get all starred projects by a user from the Gitlab API
I want to get a list of all projects that a certain user on Gitlab has starred using the Gitlab API and Python (via python-gitlab).
The documentation from python-gitlab on users does not mention ...
0
votes
2
answers
917
views
Python Gitlab API invite group to project
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....