2.9 KiB
OBS Git scmsync Workflow
This document outlines the complete workflow for how a git push to a Gitea repository triggers a source synchronization in the Open Build Service (OBS).
Components Involved
The end-to-end process involves several distinct components:
- Gitea: The Git repository hosting service.
gitea_obs_bridge: A lightweight Perl web service that acts as a webhook receiver, translating generic Git webhooks into specific OBS API calls.- OBS API (Frontend): The main entry point for the Open Build Service, built on Ruby on Rails. It handles authentication and forwards requests to the backend.
- OBS Backend Components:
bs_srcserver: The core source management server.bs_servicedispatch: Manages the dispatching of source service events.bs_service: The daemon responsible for executing source services.- SQLite DB: Stores source-related metadata, including the
scmsynctable mapping Git repositories to OBS packages.
obs-scm-bridge: A Python command-line tool installed as an OBS source service. It performs the actual Git operations (clone, fetch) to sync the sources.
Configuration
For the flow to work, two key pieces of configuration are required:
- OBS Package Configuration: The OBS package (or project) must be configured with a
<scmsync>tag in its metadata (_metafile). - Gitea Webhook: A webhook must be configured in the Gitea repository to point to the
gitea_obs_bridgeservice.
The Step-by-Step Flow
-
git push: A developer pushes new commits to a branch in a Gitea repository. -
Webhook Trigger: Gitea sends a webhook to
gitea_obs_bridge. -
API Call:
gitea_obs_bridgecalls the OBS API endpointPOST /source?cmd=triggerscmsync. -
Backend Proxy: The OBS API proxies this request directly to the
bs_srcserverbackend process. -
Lookup Involved Projects/Packages:
bs_srcserverqueries its internal SQLite database to identify all OBS projects or packages linked to the specific Git repository and branch. -
Create Service Run Events: For each identified entity, a service run event is generated. These events are handled by the
bs_servicedispatchprocess. -
Dispatch to Service Daemon:
bs_servicedispatchhands over the event to thebs_servicedaemons. -
Execute
obs-scm-bridge: The daemon executes theobs-scm-bridgesource service.- For Packages: The bridge runs similarly to a standard source service, syncing the sources directly.
- For Projects: The bridge first runs to identify all changed packages. For each changed package, a new service event is generated, triggering subsequent syncs.
Note: The OBS schedulers are designed to wait until all sources are fully updated before scheduling any new build jobs, ensuring build consistency regardless of the number of events generated.
