@@ -15,12 +15,13 @@ import {
1515import { trelloCreateWebhook , trelloDeleteWebhook , trelloListWebhooks } from './webhooks/trello.js' ;
1616import type {
1717 GitHubWebhook ,
18+ GitLabWebhookInfo ,
1819 JiraWebhookInfo ,
1920 SentryWebhookInfo ,
2021 TrelloWebhook ,
2122} from './webhooks/types.js' ;
2223
23- export type { GitHubWebhook , JiraWebhookInfo , SentryWebhookInfo , TrelloWebhook } ;
24+ export type { GitHubWebhook , GitLabWebhookInfo , JiraWebhookInfo , SentryWebhookInfo , TrelloWebhook } ;
2425
2526export const webhooksRouter = router ( {
2627 list : adminProcedure
@@ -52,9 +53,16 @@ export const webhooksRouter = router({
5253 } ;
5354 }
5455
56+ // GitLab — informational only (webhooks must be configured in GitLab UI)
57+ let gitlab : GitLabWebhookInfo [ ] | null = null ;
58+ if ( pctx . scmProvider === 'gitlab' ) {
59+ gitlab = [ ] ;
60+ }
61+
5562 return {
5663 trello : trelloResult . status === 'fulfilled' ? trelloResult . value : [ ] ,
5764 github : githubResult . status === 'fulfilled' ? githubResult . value : [ ] ,
65+ gitlab,
5866 jira : jiraResult . status === 'fulfilled' ? jiraResult . value : [ ] ,
5967 sentry,
6068 errors : {
@@ -72,6 +80,7 @@ export const webhooksRouter = router({
7280 callbackBaseUrl : z . string ( ) . url ( ) ,
7381 trelloOnly : z . boolean ( ) . optional ( ) ,
7482 githubOnly : z . boolean ( ) . optional ( ) ,
83+ gitlabOnly : z . boolean ( ) . optional ( ) ,
7584 jiraOnly : z . boolean ( ) . optional ( ) ,
7685 oneTimeTokens : oneTimeTokensSchema ,
7786 } ) ,
@@ -83,6 +92,7 @@ export const webhooksRouter = router({
8392 const results : {
8493 trello ?: TrelloWebhook | string ;
8594 github ?: GitHubWebhook | string ;
95+ gitlab ?: { url : string ; webhookSecretSet : boolean } | string ;
8696 jira ?: JiraWebhookInfo | string ;
8797 sentry ?: SentryWebhookInfo ;
8898 labelsEnsured ?: string [ ] ;
@@ -134,8 +144,22 @@ export const webhooksRouter = router({
134144 results . labelsEnsured = await jiraEnsureLabels ( pctx ) ;
135145 }
136146
147+ // GitLab — display-only (webhooks must be configured in GitLab UI)
148+ if (
149+ ! input . trelloOnly &&
150+ ! input . githubOnly &&
151+ ! input . jiraOnly &&
152+ pctx . scmProvider === 'gitlab' &&
153+ pctx . gitlabToken
154+ ) {
155+ results . gitlab = {
156+ url : `${ baseUrl } /gitlab/webhook` ,
157+ webhookSecretSet : ! ! pctx . gitlabWebhookSecret ,
158+ } ;
159+ }
160+
137161 // GitHub webhook
138- if ( ! input . trelloOnly && ! input . jiraOnly && pctx . githubToken ) {
162+ if ( ! input . trelloOnly && ! input . gitlabOnly && ! input . jiraOnly && pctx . githubToken ) {
139163 const githubCallbackUrl = `${ baseUrl } /github/webhook` ;
140164 const existing = await githubListWebhooks ( pctx ) ;
141165 const duplicate = existing . find (
@@ -168,6 +192,7 @@ export const webhooksRouter = router({
168192 callbackBaseUrl : z . string ( ) . url ( ) ,
169193 trelloOnly : z . boolean ( ) . optional ( ) ,
170194 githubOnly : z . boolean ( ) . optional ( ) ,
195+ gitlabOnly : z . boolean ( ) . optional ( ) ,
171196 jiraOnly : z . boolean ( ) . optional ( ) ,
172197 oneTimeTokens : oneTimeTokensSchema ,
173198 } ) ,
@@ -176,9 +201,10 @@ export const webhooksRouter = router({
176201 const pctx = await resolveProjectContext ( input . projectId , ctx . effectiveOrgId ) ;
177202 applyOneTimeTokens ( pctx , input . oneTimeTokens ) ;
178203 const baseUrl = input . callbackBaseUrl . replace ( / \/ $ / , '' ) ;
179- const deleted : { trello : string [ ] ; github : number [ ] ; jira : number [ ] } = {
204+ const deleted : { trello : string [ ] ; github : number [ ] ; gitlab : number [ ] ; jira : number [ ] } = {
180205 trello : [ ] ,
181206 github : [ ] ,
207+ gitlab : [ ] ,
182208 jira : [ ] ,
183209 } ;
184210
0 commit comments