Skip to content

Commit 02551e8

Browse files
authored
Merge pull request #511 from nix-community/failed-statuses
Documentation updates
2 parents c743eff + 329ec4e commit 02551e8

File tree

1 file changed

+228
-77
lines changed

1 file changed

+228
-77
lines changed

README.md

Lines changed: 228 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,13 @@ information natively as now.
107107

108108
#### Public
109109

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.
114117

115118
We have the following two roles:
116119

@@ -123,82 +126,230 @@ We have the following two roles:
123126

124127
##### Integration with GitHub
125128

126-
###### GitHub App
127-
128-
This is the preferred option to setup buildbot-nix for GitHub.
129-
130-
To integrate with GitHub using app authentication:
131-
132-
1. **GitHub App**:
133-
1. Create a new GitHub app by navigating to
134-
`https://github.com/settings/apps/new` for single-user installations or
135-
`https://github.com/organizations/<org>/settings/apps/new` for
136-
organisations where `<org>` is the name of your GitHub organizaction.
137-
2. GitHub App Name: "buildbox-nix <org>"
138-
3. Homepage URL: `https://buildbot.<your-domain>`
139-
4. Callback URL: `https://buildbot.<your-domain>/auth/login`.
140-
5. Disable the Webhook
141-
6. Repository Permissions:
142-
- Contents: Read-only
143-
- Commit statuses: Read and write
144-
- Metadata: Read-only
145-
- Webhooks: Read and write
146-
7. Organisation Permissions (only if you create this app for an
147-
organisation):
148-
- Members: Read-only
149-
2. **GitHub App private key**: Get the app private key and app ID from GitHub,
150-
configure using the buildbot-nix NixOS module.
151-
- Set
152-
`services.buildbot-nix.master.github.authType.app.id = <your-github-id>;`
153-
- Set
154-
`services.buildbot-nix.master.github.authType.app.secretKeyFile = "/path/to.pem";`
155-
3. **Install App**: Install the app for an organization or specific user.
156-
4. **Refresh GitHub Projects**: Currently buildbot-nix doesn't respond to
157-
changes (new repositories or installations) automatically, it is therefore
158-
necessary to manually trigger a reload or wait for the next periodic reload.
159-
160-
###### Token Auth
161-
162-
To integrate with GitHub using legacy token authentication:
163-
164-
1. **GitHub Token**: Obtain a GitHub token with `admin:repo_hook` and `repo`
165-
permissions. For GitHub organizations, it's advisable to create a separate
166-
GitHub user for managing repository webhooks.
167-
168-
##### Optional when using GitHub login
169-
170-
1. **GitHub App**: Set up a GitHub app for Buildbot to enable GitHub user
171-
authentication on the Buildbot dashboard. (can be the same as for GitHub App
172-
auth)
173-
2. **OAuth Credentials**: After installing the app, generate OAuth credentials
174-
and configure them in the buildbot-nix NixOS module. Set the callback url to
175-
`https://<your-domain>/auth/login`.
176-
177-
Afterwards add the configured github topic to every project that should build
178-
with buildbot-nix. Notice that the buildbot user needs to have admin access to
179-
this repository because it needs to install a webhook.
129+
Buildbot-nix uses GitHub App authentication to integrate with GitHub
130+
repositories. This enables automatic webhook setup, commit status updates, and
131+
secure authentication.
132+
133+
###### Step 1: Create a GitHub App
134+
135+
1. Navigate to:
136+
- For personal accounts: `https://github.com/settings/apps/new`
137+
- For organizations:
138+
`https://github.com/organizations/<org>/settings/apps/new`
139+
140+
2. Configure the app with these settings:
141+
- **GitHub App Name**: `buildbot-nix-<org>` (or any unique name)
142+
- **Homepage URL**: `https://buildbot.<your-domain>`
143+
- **Webhook**: Disable (buildbot-nix creates webhooks per repository)
144+
- **Callback URL** (optional, for OAuth):
145+
`https://buildbot.<your-domain>/auth/login`
146+
147+
3. Set the required permissions:
148+
- **Repository Permissions:**
149+
- Contents: Read-only (to clone repositories)
150+
- Commit statuses: Read and write (to report build status)
151+
- Metadata: Read-only (basic repository info)
152+
- Webhooks: Read and write (to automatically create webhooks)
153+
- **Organization Permissions** (if app is for an organization):
154+
- Members: Read-only (to verify organization membership for access control)
155+
156+
4. After creating the app:
157+
- Note the **App ID**
158+
- Generate and download a **private key** (.pem file)
159+
160+
###### Step 2: Configure buildbot-nix
161+
162+
Add the GitHub configuration to your NixOS module:
163+
164+
```nix
165+
services.buildbot-nix.master = {
166+
authBackend = "github";
167+
github = {
168+
authType.app = {
169+
id = <your-app-id>; # The numeric App ID
170+
secretKeyFile = "/path/to/private-key.pem"; # Path to the downloaded private key
171+
};
172+
173+
# Optional: Enable OAuth for user login
174+
oauth = {
175+
id = "<oauth-client-id>";
176+
secretFile = "/path/to/oauth-secret";
177+
};
178+
179+
# Optional: Filter which repositories to build
180+
topic = "buildbot-nix"; # Only build repos with this topic
181+
};
182+
};
183+
```
184+
185+
###### Step 3: Install the GitHub App
186+
187+
1. Go to your app's settings page
188+
2. Click "Install App" and choose which repositories to grant access
189+
3. The app needs access to all repositories you want to build with buildbot-nix
190+
191+
###### Step 4: Repository Configuration
192+
193+
For each repository you want to build:
194+
195+
1. **Add the configured topic** (if using topic filtering):
196+
- Go to repository settings
197+
- Add the topic (e.g., `buildbot-nix`) to enable builds
198+
199+
2. **Automatic webhook creation**:
200+
- Buildbot-nix automatically creates webhooks when:
201+
- Projects are loaded on startup
202+
- The project list is manually reloaded
203+
- The webhook will be created at:
204+
`https://buildbot.<your-domain>/change_hook/github`
205+
206+
###### How It Works
207+
208+
- **Authentication**: Uses GitHub App JWT tokens for API access and installation
209+
tokens for repository-specific operations
210+
- **Project Discovery**: Automatically discovers repositories the app has access
211+
to, filtered by topic if configured
212+
- **Webhook Management**: Automatically creates and manages webhooks for push
213+
and pull_request events
214+
- **Status Updates**: Reports build status back to GitHub commits and pull
215+
requests
216+
- **Access Control**:
217+
- Admins: Configured users can reload projects and manage builds
218+
- Organization members: Can restart their own builds
219+
220+
###### Troubleshooting
221+
222+
- **Projects not appearing**: Check that:
223+
- The GitHub App is installed for the repository
224+
- The repository has the configured topic (if filtering by topic)
225+
- Reload projects manually through the Buildbot UI
226+
227+
- **Webhooks not created**: Verify the app has webhook write permission for the
228+
repository
229+
230+
- **Authentication issues**: Ensure the private key file is readable by the
231+
buildbot service
180232

181233
##### Integration with Gitea
182234

183-
To integrate with Gitea
184-
185-
1. **Gitea Token** Obtain a Gitea token with the following permissions
186-
`write:repository` and `write:user` permission. For Gitea organizations, it's
187-
advisable to create a separate Gitea user. Buildbot-nix will use this token
188-
to automatically setup a webhook in the repository.
189-
2. **Gitea App**: (optional). This is optional, when using GitHub as the
190-
authentication backend for buildbot. Set up a OAuth2 app for Buildbot in the
191-
Applications section. This can be done in the global "Site adminstration"
192-
settings (only available for admins) or in a Gitea organisation or in your
193-
personal settings. As redirect url set
194-
`https://buildbot.your-buildbot-domain.com/auth/login`, where
195-
`buildbot.your-buildbot-domain.com` should be replaced with the actual domain
196-
that your buildbot is running on.
197-
198-
Afterwards add the configured gitea topic to every project that should build
199-
with buildbot-nix. Notice that the buildbot user needs to have repository write
200-
access to this repository because it needs to install a webhook in the
201-
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
202353

203354
#### Fully Private
204355

0 commit comments

Comments
 (0)