[GSoC] Gitlab support in Packit-Service (Fedora)

Shreyas Papinwar
3 min readAug 28, 2020

--

Hi! I have been working on adding support of packit-service on GitLab, and this is my final report/work.

Description

The goal of the project is to make packit-service work on GitLab, so that it can process events from GitLab and return feedback of successful builds or failed tests back into the merge request.

Workings and Deployment

Packit Service now supports copr-build on GitLab🎉

  • I worked on GitLab authentication workflow where you get unique token for your project to authenticate with packit. In the later part of the blog I have shown the working of it.
  • Now packit service sends build status in 2 ways.
  1. Build status as commit status when packit-user has the project access.
  2. Build status of the merge requests as comments.

Here I will show how to use packit-service on GitLab.

In this example, I have cloned the ogr repository from github to shreyaspapi/ogr.

Adding webhook to your project

Now in order to send events to packit-service we need to setup webhook for the project by going to Settings -> Webhooks

Here, I am using my own packit instance (URL will be https://prod.packit.dev/api/webhooks/gitlab).

Select the triggers (with minimum trigger permissions of Push events, Comments, Issue events, Merge request events) and Enable SSL verification than add webhook.

Now after adding the webhook, packit will create a confidential issue in the repository.

Confidential issue created by packit-service

Only users with the right access to the project will be able to see the confidential issues.

Follow the steps from the issue description by adding the unique secret token sent by packit for your repository. Edit the webhook setting you added earlier with the secret token written in the issue.

Now for packit to send build status to your merge requests you will need to give admin access to the packit user defined in the issue.

You need to add packit config file to your repository to know more about it click here.

To check if Packit Service works in your project, create a merge request, Packit Service builds the code from the merge request in COPR repository and reports back COPR build status to the merge request.

Here is an example of the merge request build status -

https://gitlab.com/shreyaspapi/ogr/-/merge_requests/1

Currently, GitLab only supports copr-build.

To retrigger the build you can comment to merge request as

/packit copr-build

Now, here is another example of how Packit Service will send build status to merge request when packit (user) does not have the permission to the repository https://gitlab.com/shreyaspapi/ogr/-/merge_requests/2.

Work Achieved

  • Packit-service can now parse GitLab events #629
  • Handing webhook authentication coming from GitLab instance #769
  • Report successful builds or failed tests back into the merge request #740
  • Added copr-build job #683
  • Ogr can now request project access. #439
  • Added support to create private issues #441
  • Fixed inconsistency of create issues in ogr #451
  • Packit checkout_pr for GitLab #926

That’s it for now!

--

--