Skip to content
Advertisement

How to create a new branch, push a text file and send merge request to a gitlab repository using Python?

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

Advertisement

Answer

That’s right there are no tests we can find in the doc. Here’s a basic answer for your question.

If you would like a complete working script, I have attached it here: https://github.com/torpidsnake/common_scripts/blob/main/automation_to_create_push_merge_in_gitlab/usecase_gitlab_python.py

Breaking down the steps below:

Create an authkey for you: Follow the steps here: https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html

Create a gitlab server instance of your project

JavaScript

Create a branch using:

JavaScript

Upload a file using:

JavaScript

Create a merge request using:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement