@@ -107,10 +107,13 @@ information natively as now.
107
107
108
108
#### Public
109
109
110
- For some actions a login is required. This login can either be based on GitHub
111
- or on Gitea (more logins may follow). The backend is set by the
112
- ` services.buildbot-nix.master.authBackend ` NixOS option ("gitea"/"github",
113
- "github" by default).
110
+ For some actions a login is required. The authentication backend is set by the
111
+ ` services.buildbot-nix.master.authBackend ` NixOS option ("github", "gitea", or
112
+ others).
113
+
114
+ ** Note** : You can configure both GitHub and Gitea integrations simultaneously,
115
+ regardless of which authentication backend you choose. The auth backend only
116
+ determines how users log in to the Buildbot interface.
114
117
115
118
We have the following two roles:
116
119
@@ -229,25 +232,124 @@ For each repository you want to build:
229
232
230
233
##### Integration with Gitea
231
234
232
- To integrate with Gitea
233
-
234
- 1 . ** Gitea Token** Obtain a Gitea token with the following permissions
235
- ` write:repository ` and ` write:user ` permission. For Gitea organizations, it's
236
- advisable to create a separate Gitea user. Buildbot-nix will use this token
237
- to automatically setup a webhook in the repository.
238
- 2 . ** Gitea App** : (optional). This is optional, when using GitHub as the
239
- authentication backend for buildbot. Set up a OAuth2 app for Buildbot in the
240
- Applications section. This can be done in the global "Site adminstration"
241
- settings (only available for admins) or in a Gitea organisation or in your
242
- personal settings. As redirect url set
243
- ` https://buildbot.your-buildbot-domain.com/auth/login ` , where
244
- ` buildbot.your-buildbot-domain.com ` should be replaced with the actual domain
245
- that your buildbot is running on.
246
-
247
- Afterwards add the configured gitea topic to every project that should build
248
- with buildbot-nix. Notice that the buildbot user needs to have repository write
249
- access to this repository because it needs to install a webhook in the
250
- repository.
235
+ Buildbot-nix integrates with Gitea using access tokens for repository management
236
+ and OAuth2 for user authentication. This enables automatic webhook setup, commit
237
+ status updates, and secure authentication.
238
+
239
+ ###### Step 1: Create a Gitea Access Token
240
+
241
+ 1 . ** Create a dedicated Gitea user** (recommended for organizations):
242
+ - This user will manage webhooks and report build statuses
243
+ - Add this user as a collaborator to all repositories you want to build
244
+
245
+ 2 . ** Generate an access token** :
246
+ - Log in as the dedicated user
247
+ - Go to Settings → Applications → Generate New Token
248
+ - Required permissions:
249
+ - ` write:repository ` - To create webhooks and update commit statuses
250
+ - ` write:user ` - To access user information
251
+ - Save the token securely
252
+
253
+ ###### Step 2: Set up OAuth2 Authentication (for user login)
254
+
255
+ 1 . ** Create an OAuth2 Application** :
256
+ - Navigate to one of these locations:
257
+ - Site Administration → Applications (for admins, applies globally)
258
+ - Organization Settings → Applications (for organization-wide access)
259
+ - User Settings → Applications (for personal use)
260
+
261
+ 2 . ** Configure the OAuth2 app** :
262
+ - ** Application Name** : ` buildbot-nix `
263
+ - ** Redirect URI** : ` https://buildbot.<your-domain>/auth/login `
264
+
265
+ 3 . ** Note the credentials** :
266
+ - Client ID
267
+ - Client Secret
268
+
269
+ ###### Step 3: Configure buildbot-nix
270
+
271
+ Add the Gitea configuration to your NixOS module:
272
+
273
+ ``` nix
274
+ services.buildbot-nix.master = {
275
+ authBackend = "gitea";
276
+ gitea = {
277
+ enable = true;
278
+ instanceUrl = "https://gitea.example.com";
279
+
280
+ # Access token for API operations
281
+ tokenFile = "/path/to/gitea-token";
282
+ webhookSecretFile = "/path/to/webhook-secret";
283
+
284
+ # OAuth2 for user authentication
285
+ oauth = {
286
+ id = "<oauth-client-id>";
287
+ secretFile = "/path/to/oauth-secret";
288
+ };
289
+
290
+ # Optional: SSH authentication for private repositories
291
+ sshPrivateKeyFile = "/path/to/ssh-key";
292
+ sshKnownHostsFile = "/path/to/known-hosts";
293
+
294
+ # Optional: Filter which repositories to build
295
+ topic = "buildbot-nix"; # Only build repos with this topic
296
+ };
297
+ };
298
+ ```
299
+
300
+ ###### Step 4: Repository Configuration
301
+
302
+ For each repository you want to build:
303
+
304
+ 1 . ** Grant repository access** :
305
+ - Add the buildbot user as a collaborator with admin access
306
+ - Admin access is required for webhook creation
307
+
308
+ 2 . ** Add the configured topic** (if using topic filtering):
309
+ - Go to repository settings
310
+ - Add the topic (e.g., ` buildbot-nix ` ) to enable builds
311
+
312
+ 3 . ** Automatic webhook creation** :
313
+ - Buildbot-nix automatically creates webhooks when:
314
+ - Projects are loaded on startup
315
+ - The project list is manually reloaded
316
+ - The webhook will be created at:
317
+ ` https://buildbot.<your-domain>/change_hook/gitea `
318
+ - Webhook events: ` push ` and ` pull_request `
319
+
320
+ ###### How It Works
321
+
322
+ - ** Authentication** : Uses Gitea access tokens for API operations
323
+ - ** Project Discovery** : Automatically discovers repositories where the buildbot
324
+ user has admin access, filtered by topic if configured
325
+ - ** Webhook Management** : Automatically creates and manages webhooks for push
326
+ and pull_request events
327
+ - ** Status Updates** : Reports build status back to Gitea commits and pull
328
+ requests
329
+ - ** Access Control** :
330
+ - Admins: Configured users can reload projects and manage builds
331
+ - Organization members: Can restart their own builds (when OAuth is
332
+ configured)
333
+ - ** Repository Access** : Can use either HTTPS (with token) or SSH authentication
334
+ for cloning private repositories
335
+
336
+ ###### Troubleshooting
337
+
338
+ - ** Projects not appearing** : Check that:
339
+ - The buildbot user has admin access to the repository
340
+ - The repository has the configured topic (if filtering by topic)
341
+ - The access token has the correct permissions
342
+ - Reload projects manually through the Buildbot UI
343
+
344
+ - ** Webhooks not created** : Verify the buildbot user has admin permissions on
345
+ the repository
346
+
347
+ - ** Authentication issues** :
348
+ - Ensure the access token is valid and has required permissions
349
+ - For OAuth issues, verify the redirect URI matches exactly
350
+
351
+ - ** Private repositories** : If using SSH, ensure the SSH key is properly
352
+ configured and the known_hosts file contains the Gitea server
251
353
252
354
#### Fully Private
253
355
0 commit comments