No video

047 Introduction to GitLab REST API and python-gitlab

  Рет қаралды 20,681

Dan Gitschooldude

Dan Gitschooldude

Күн бұрын

In today's video we go through three examples of using the GitLab REST API via the python-gitlab interface. With just a few lines of code we list every merge request in a project, post a message to an existing merge request, and create a new issue. I conclude by discussing some real-life use cases for this capability.
Hello world project: gitlab.com/git...
Merge request used in this video: gitlab.com/git...
GitLab API Documentation: docs.gitlab.co...
Python-Gitlab Documentation: python-gitlab....
If you are looking for an effective concise introduction to Git, I highly recommend my "Fundamentals of Git" course on Udemy: www.udemy.com/...
If you or your company is interested in live virtual software and tools training, see www.continuous... for a list of training topics we offer.

Пікірлер: 49
@jonnykopp
@jonnykopp 3 жыл бұрын
I hope all is well. I check this channel several times a month looking for updates I've missed. I'd love a series looking over your shoulder as you contribute to another project. Just to see the whole process step by step putting everything together. Thanks again for everything you've covered, it's really appreciated.
@DanGitschooldude
@DanGitschooldude 3 жыл бұрын
Thanks buddy I appreciate that. I've considered a series like that but have been quite busy recently. I'm hoping to get some more video content out in the coming months.
@jonnykopp
@jonnykopp 3 жыл бұрын
@@DanGitschooldude No rush, glad all sounds to be well. Take care of yourself.
@DeadPanda95
@DeadPanda95 3 жыл бұрын
Hi Dan, thank you so much for making this! it's super accessible and clear and the sprinkling of humour was a really nice touch
@geraldimhof2875
@geraldimhof2875 2 жыл бұрын
shoutout to your whole playlist and this vid in particular. I'm developing an event based python script for work. This is a massive help!
@johnborland3855
@johnborland3855 4 жыл бұрын
I would love to know more about web hooks!
@DanGitschooldude
@DanGitschooldude 4 жыл бұрын
I have a feeling this dude is hilarious. Just a hunch.
@jonnykopp
@jonnykopp 4 жыл бұрын
Great video!! Thanks again for all the content on this channel.
@DanGitschooldude
@DanGitschooldude 4 жыл бұрын
You bet!
@mekam3963
@mekam3963 Жыл бұрын
I would like a webhooks. I also haven’t checked out your other videos yet! Good explanations
@ceciliogarcia6281
@ceciliogarcia6281 4 жыл бұрын
Webhook integration video pleaaase!!
@DanGitschooldude
@DanGitschooldude 4 жыл бұрын
Thanks for watching! Webhook video is officially on the list.
@Being_Joe
@Being_Joe 3 жыл бұрын
This look useful. I been interacting with the GL API with raw python but this library may be useful if anything to study the code.
@FrankGraffagnino
@FrankGraffagnino 4 жыл бұрын
cool video bruh!
@DanGitschooldude
@DanGitschooldude 4 жыл бұрын
Thanks!
@be236
@be236 4 жыл бұрын
I needed to automate some GitLab operations... was considering to use bash with curl commands... watching this video using Python to do this is interesting...so I'm torn between using bash or Python now...
@DanGitschooldude
@DanGitschooldude 4 жыл бұрын
bash/curl works well for something simple, I prefer python for more complicated mechanisms. Thanks for watching!
@meranaammujahid
@meranaammujahid Жыл бұрын
Hey Dan, i need to create a new gitlab project from another gitlab project's CICD pipeline. how can i do that using the above method?
@anamikamaheshwari
@anamikamaheshwari 2 жыл бұрын
Hello Den, I want to read merge request details (desired: label) during pipeline running from Jenkins. Is it possible , if yes please help me
@samstrevens4630
@samstrevens4630 2 жыл бұрын
Hey Dan, this is a great video, very helpful. Would you happen to know if you can call a template file (.md) for the description when creating a new issue via the script?
@DanGitschooldude
@DanGitschooldude 2 жыл бұрын
Good question - it doesn't look like the API supports a template file according to the documentation: docs.gitlab.com/ee/api/issues.html#new-issue . I guess if you have access to the *.md files in your REST-calling script you could use it in the "description" section of the new issue directly.
@eftinga
@eftinga 3 жыл бұрын
Is it possible to use project tokens, but still have issues created associated with a specific user?
@DanGitschooldude
@DanGitschooldude 3 жыл бұрын
Everything done through the API will be done as the user from which the token was generated. Assignment of the issue is independent from the issue creation. There are ways to get users from the API as well, check out the documentation in the description.
@geraldimhof2875
@geraldimhof2875 2 жыл бұрын
speaking of which... I wrote a script to basically fetch and write all commits date and title into a markdown logbook file. However, I want this to be automatically run on the remote when a commit is made.. aka user commits->auto run script-> new addition to the logbook. Not entirely sure wether it's possible or not. If it is, what should I look for in terms of info/tutorials etc?
@DanGitschooldude
@DanGitschooldude 2 жыл бұрын
A weird use case, but yeah you'd write a post commit hook script that makes a rest API call to modify the wiki. docs.gitlab.com/ee/api/wikis.html#edit-an-existing-wiki-page Now I'm curious, what's the use case? Why do you want a log of every commit made across all repo clients?
@geraldimhof2875
@geraldimhof2875 2 жыл бұрын
@@DanGitschooldude haha.. well I'm an Assembly and Integration engineer in aerospace. I'm developing an open source tool for the documentation (like test procedures on a part, reception control of a part) and we need a thorough logging of every document uploaded on the Gitlab, to be able to trace back every single action made during the integration and testing. all of that in an easily accessible and readable manner for anyone
@DanGitschooldude
@DanGitschooldude 2 жыл бұрын
Interesting. There may be easier ways to get the information you're after. For example the gitlab wiki for each project is a git repo itself. 'git log' by definition is a list of the commits, that seems close to what you describe as the requirements. With the post-commit hook approach I described there could be edge cases that could be a problem. What happens if local history is rewritten after the hook runs? The wiki could show commits that never make it to the remote. Anywho just something else I consider. If your open source project is public send me a link if be curious to peruse it. 😎
@geraldimhof2875
@geraldimhof2875 2 жыл бұрын
@@DanGitschooldude not Public unfortunately. But the end result will be open source next year (hopefully)
@pavankr400
@pavankr400 3 жыл бұрын
Hey, I am using python-gitlab for downloading a build from a gitlab account. I have a p12 file which I am adding as a certificate to the browser and is working fine in the browser. But when I add the same certificate in the python-gitlab session argument, it says "GitlabParsingError - Unable to parse contents from the server" Do you have any solution for this? All I have is the username, password, token and a p12 certificate to the git lab account
@follyfelixmagloireamaizo3155
@follyfelixmagloireamaizo3155 4 жыл бұрын
Thank you for this video. I have a quick question: I was able to comment a commit using the python-gitlab API but I would need to upload a file along with the comment of the commit. Do you know if that is possible? I am blocked with that
@codewithvinod9033
@codewithvinod9033 3 жыл бұрын
kzfaq.info/get/bejne/js-HerV3xKfKYZc.html
@pierreblanchet6955
@pierreblanchet6955 4 жыл бұрын
Hey ! Thanks for the vid it was great and explained a lot :) I have a question : What if I want to create a job in my gitlab-ci.yml file that will launch a python script that will interact with gitlab API. How can I use the library python-gitlab (considering it's not installed on the machine where the runner is ?)
@DanGitschooldude
@DanGitschooldude 4 жыл бұрын
You should be able to 'pip install python-gitlab' in your CI job before you run your script. Check out their documentation and thanks for watching! python-gitlab.readthedocs.io/en/stable/install.html
@blissfulshanvika460
@blissfulshanvika460 3 жыл бұрын
Is this GIT playlist covers complete GIT? I mean from From 0 to advanced ?
@DanGitschooldude
@DanGitschooldude 3 жыл бұрын
It starts at zero and covers many advanced topics but I wouldn't say it's complete.
@codewithvinod9033
@codewithvinod9033 3 жыл бұрын
kzfaq.info/get/bejne/js-HerV3xKfKYZc.html
@Nikita-xk9fc
@Nikita-xk9fc 3 жыл бұрын
Hey I want a help. There's a project on gitlab.corp.mycompany.com and I want to access the list on its board. I tried with the above method through curl using the gitlab documentation but it just displays redirecting to login page within html tags in console. So, do I need to ask the access token to the admin of that project to access it? Thanks in advance
@DanGitschooldude
@DanGitschooldude 3 жыл бұрын
Regardless of gitlab instance, you will need to authenticate via some method to use the REST API, unless gitlab and the project are configured to be public w/ no login (which is rare). So yes you'll need to get access to that instance one way or another in order to generate a token for authentication.
@Nikita-xk9fc
@Nikita-xk9fc 3 жыл бұрын
@@DanGitschooldude thanks . Will ask for the write access for that project then.
@saishanoor2763
@saishanoor2763 4 жыл бұрын
How to get all file names via python gitlab?
@DanGitschooldude
@DanGitschooldude 4 жыл бұрын
You probably want this: python-gitlab.readthedocs.io/en/stable/api/gitlab.v4.html?highlight=compare#gitlab.v4.objects.Project.repository_tree
@radiant_rhea
@radiant_rhea 4 жыл бұрын
Can we use SSH key instead of Tokens?
@DanGitschooldude
@DanGitschooldude 4 жыл бұрын
Not that I'm aware of. The REST interface is HTTPS not SSH. Thanks for watching!
@radiant_rhea
@radiant_rhea 4 жыл бұрын
@@DanGitschooldude makes sense. Theoretically we can encrypt using private key and git can confirm our identity using public key we'd have setup during ssh key set up, and then carry on with mutual AES key, but that won't be ideal.
"Fundamentals of Git" Udemy Course Preview and Full Course Giveaway
46:00
Dan Gitschooldude
Рет қаралды 1,7 М.
008 Introduction to Git Submodules
26:52
Dan Gitschooldude
Рет қаралды 71 М.
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 1,2 МЛН
Kind Waiter's Gesture to Homeless Boy #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 12 МЛН
028 Introduction to Gitlab CI
20:43
Dan Gitschooldude
Рет қаралды 46 М.
Turns out REST APIs weren't the answer (and that's OK!)
10:38
Dylan Beattie
Рет қаралды 145 М.
How To Call a REST API In Java - Simple Tutorial
29:14
Coding with John
Рет қаралды 267 М.
GitLab CI CD Pipeline Tutorial | Introduction | 2022
34:43
Tech and Beyond With Moss
Рет қаралды 238 М.
Advanced pipelines using .gitlab-ci.yml
14:58
Tomek Święcicki
Рет қаралды 26 М.
045 Introduction to Git LFS (Large File Storage)
14:41
Dan Gitschooldude
Рет қаралды 54 М.
GitLab CI/CD Rules
8:57
GitLab Unfiltered
Рет қаралды 18 М.
016 Introduction to Git cherry-pick
13:16
Dan Gitschooldude
Рет қаралды 77 М.
How to run Postman API Tests with Newman in Gitlab CI
13:23
Valentin Despa
Рет қаралды 37 М.