feat: link commits, branches and pull requests to tickets

A project can turn on a webhook for GitHub, Gitea or GitLab. Pushes and
pull or merge requests that name a ticket key show on that ticket under
Desarrollo, with the state of each pull request; the secret is shown and
rotated from the project settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 15:28:12 +02:00
parent 24b37b6628
commit 046d77c813
48 changed files with 2638 additions and 12 deletions

View File

@@ -7561,6 +7561,316 @@
"Sprints"
]
}
},
"/api/projects/{project}/git-integration": {
"get": {
"operationId": "GitController_integration",
"parameters": [
{
"name": "project",
"required": true,
"in": "path",
"description": "Project id or key",
"schema": {
"example": "WEB",
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GitIntegrationDto"
}
}
}
},
"400": {
"description": "Invalid input",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"401": {
"description": "Missing or rejected Pireon token",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"403": {
"description": "Not a member of the project (or not allowed)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
}
},
"security": [
{
"pireon-oauth": []
},
{
"pireon": []
}
],
"summary": "Whether the Git webhook is on (and its secret, for admins)",
"tags": [
"Git"
]
},
"post": {
"operationId": "GitController_enable",
"parameters": [
{
"name": "project",
"required": true,
"in": "path",
"description": "Project id or key",
"schema": {
"example": "WEB",
"type": "string"
}
}
],
"responses": {
"201": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GitIntegrationDto"
}
}
}
},
"400": {
"description": "Invalid input",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"401": {
"description": "Missing or rejected Pireon token",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"403": {
"description": "Not a member of the project (or not allowed)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"409": {
"description": "Someone changed it at the same time: retry",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"422": {
"description": "Business rule (e.g. a transition the workflow forbids)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
}
},
"security": [
{
"pireon-oauth": []
},
{
"pireon": []
}
],
"summary": "Turn the Git webhook on with a new secret (or rotate it)",
"tags": [
"Git"
]
},
"delete": {
"operationId": "GitController_disable",
"parameters": [
{
"name": "project",
"required": true,
"in": "path",
"description": "Project id or key",
"schema": {
"example": "WEB",
"type": "string"
}
}
],
"responses": {
"204": {
"description": ""
},
"400": {
"description": "Invalid input",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"401": {
"description": "Missing or rejected Pireon token",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"403": {
"description": "Not a member of the project (or not allowed)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"409": {
"description": "Someone changed it at the same time: retry",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"422": {
"description": "Business rule (e.g. a transition the workflow forbids)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
}
},
"security": [
{
"pireon-oauth": []
},
{
"pireon": []
}
],
"summary": "Turn the Git webhook off",
"tags": [
"Git"
]
}
},
"/api/webhooks/git/{project}": {
"post": {
"description": "Push and pull/merge request events. GitHub and Gitea sign the body with the secret (HMAC-SHA256); GitLab sends it as X-Gitlab-Token. Other events are acknowledged and ignored.",
"operationId": "GitController_receive",
"parameters": [
{
"name": "project",
"required": true,
"in": "path",
"description": "Project id or key",
"schema": {
"example": "WEB",
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GitDeliveryResultDto"
}
}
}
},
"403": {
"description": "Unknown project, integration off or bad signature"
}
},
"summary": "Webhook for GitHub, Gitea or GitLab (called by the Git host)",
"tags": [
"Git"
],
"security": []
}
}
},
"info": {
@@ -8582,6 +8892,74 @@
"done"
]
},
"DevLinkKind": {
"type": "string",
"enum": [
"COMMIT",
"BRANCH",
"PULL_REQUEST"
]
},
"DevLinkState": {
"type": "string",
"enum": [
"OPEN",
"MERGED",
"CLOSED"
]
},
"DevLinkDto": {
"type": "object",
"properties": {
"kind": {
"allOf": [
{
"$ref": "#/components/schemas/DevLinkKind"
}
]
},
"url": {
"type": "string"
},
"title": {
"type": "string"
},
"ref": {
"type": "string",
"description": "Short SHA, branch or PR number"
},
"state": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/DevLinkState"
}
]
},
"provider": {
"type": "string",
"example": "gitea"
},
"author": {
"type": "string",
"nullable": true
},
"at": {
"type": "string",
"format": "date-time"
}
},
"required": [
"kind",
"url",
"title",
"ref",
"state",
"provider",
"author",
"at"
]
},
"IssueDto": {
"type": "object",
"properties": {
@@ -8744,6 +9122,13 @@
"$ref": "#/components/schemas/ChecklistItemDto"
}
},
"devLinks": {
"description": "Commits, branches and pull requests that mention it",
"type": "array",
"items": {
"$ref": "#/components/schemas/DevLinkDto"
}
},
"commentCount": {
"type": "number"
},
@@ -8788,6 +9173,7 @@
"parent",
"rank",
"checklist",
"devLinks",
"commentCount",
"createdAt",
"updatedAt",
@@ -10395,6 +10781,40 @@
"required": [
"sprintId"
]
},
"GitIntegrationDto": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"secret": {
"type": "string",
"nullable": true,
"description": "Webhook secret; only owners and admins see it"
},
"webhookPath": {
"type": "string",
"example": "/api/webhooks/git/3f2c…"
}
},
"required": [
"enabled",
"secret",
"webhookPath"
]
},
"GitDeliveryResultDto": {
"type": "object",
"properties": {
"recorded": {
"type": "number",
"description": "Tickets that got something new"
}
},
"required": [
"recorded"
]
}
}
}

View File

@@ -203,6 +203,34 @@ type CumulativeFlow {
series: [FlowSeries!]!
}
"""A commit, branch or pull request that mentions the ticket"""
type DevLink {
at: String!
author: String
kind: DevLinkKind!
"""github, gitea or gitlab"""
provider: String!
"""Short SHA, branch or PR number"""
ref: String!
state: DevLinkState
title: String!
url: String!
}
enum DevLinkKind {
BRANCH
COMMIT
PULL_REQUEST
}
enum DevLinkState {
CLOSED
MERGED
OPEN
}
type DurationStats {
averageDays: Float
count: Int!
@@ -222,6 +250,19 @@ type FlowSeries {
status: String!
}
"""
Webhook from GitHub, Gitea or GitLab: commits, branches and pull requests naming a ticket key are linked to it
"""
type GitIntegration {
enabled: Boolean!
"""Webhook secret; only owners and admins see it"""
secret: String
"""Path of the webhook on this API"""
webhookPath: String!
}
type Issue {
"""Statuses this ticket can move to next (project's workflow)"""
allowedTransitions: [String!]!
@@ -235,6 +276,9 @@ type Issue {
comments(limit: Int! = 50, offset: Int! = 0): CommentPage!
createdAt: String!
description: String
"""Commits, branches and pull requests that mention it"""
devLinks: [DevLink!]!
dueDate: String
figmaUrl: String
@@ -435,8 +479,12 @@ type Mutation {
"""Delete a sprint that never started; its tickets go back to the backlog"""
deleteSprint(sprintId: ID!): CommandResult!
disableGitIntegration(projectId: ID!): Boolean!
editComment(body: String!, commentId: ID!): CommandResult!
"""Turn the Git webhook on, with a new secret (also to rotate it)"""
enableGitIntegration(projectId: ID!): GitIntegration!
"""Relate tickets, e.g. FE DEPENDS_ON BE, QA TESTS FE"""
linkIssues(input: LinkIssuesInput!): CommandResult!
@@ -681,6 +729,7 @@ type Query {
A project's epics: top-level tickets that group others, with the progress of those
"""
epics(projectId: ID!): [Epic!]!
gitIntegration(projectId: ID!): GitIntegration!
issue(
"""Issue id or key (e.g. "TS-42")"""
idOrKey: String!

View File

@@ -1097,6 +1097,45 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/projects/{project}/git-integration": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** Whether the Git webhook is on (and its secret, for admins) */
get: operations["GitController_integration"];
put?: never;
/** Turn the Git webhook on with a new secret (or rotate it) */
post: operations["GitController_enable"];
/** Turn the Git webhook off */
delete: operations["GitController_disable"];
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/webhooks/git/{project}": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/**
* Webhook for GitHub, Gitea or GitLab (called by the Git host)
* @description Push and pull/merge request events. GitHub and Gitea sign the body with the secret (HMAC-SHA256); GitLab sends it as X-Gitlab-Token. Other events are acknowledged and ignored.
*/
post: operations["GitController_receive"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
@@ -1417,6 +1456,23 @@ export interface components {
text: string;
done: boolean;
};
/** @enum {string} */
DevLinkKind: "COMMIT" | "BRANCH" | "PULL_REQUEST";
/** @enum {string} */
DevLinkState: "OPEN" | "MERGED" | "CLOSED";
DevLinkDto: {
kind: components["schemas"]["DevLinkKind"];
url: string;
title: string;
/** @description Short SHA, branch or PR number */
ref: string;
state: components["schemas"]["DevLinkState"] | null;
/** @example gitea */
provider: string;
author: string | null;
/** Format: date-time */
at: string;
};
IssueDto: {
/** Format: uuid */
id: string;
@@ -1473,6 +1529,8 @@ export interface components {
/** @description Place in the backlog and its board column (ascending, as text) */
rank: string;
checklist: components["schemas"]["ChecklistItemDto"][];
/** @description Commits, branches and pull requests that mention it */
devLinks: components["schemas"]["DevLinkDto"][];
commentCount: number;
/** Format: date-time */
createdAt: string;
@@ -2029,6 +2087,17 @@ export interface components {
*/
sprintId: string | null;
};
GitIntegrationDto: {
enabled: boolean;
/** @description Webhook secret; only owners and admins see it */
secret: string | null;
/** @example /api/webhooks/git/3f2c… */
webhookPath: string;
};
GitDeliveryResultDto: {
/** @description Tickets that got something new */
recorded: number;
};
};
responses: never;
parameters: never;
@@ -7233,4 +7302,241 @@ export interface operations {
};
};
};
GitController_integration: {
parameters: {
query?: never;
header?: never;
path: {
/** @description Project id or key */
project: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["GitIntegrationDto"];
};
};
/** @description Invalid input */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Missing or rejected Pireon token */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Not a member of the project (or not allowed) */
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Not found */
404: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
};
};
GitController_enable: {
parameters: {
query?: never;
header?: never;
path: {
/** @description Project id or key */
project: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
201: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["GitIntegrationDto"];
};
};
/** @description Invalid input */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Missing or rejected Pireon token */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Not a member of the project (or not allowed) */
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Not found */
404: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Someone changed it at the same time: retry */
409: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Business rule (e.g. a transition the workflow forbids) */
422: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
};
};
GitController_disable: {
parameters: {
query?: never;
header?: never;
path: {
/** @description Project id or key */
project: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
204: {
headers: {
[name: string]: unknown;
};
content?: never;
};
/** @description Invalid input */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Missing or rejected Pireon token */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Not a member of the project (or not allowed) */
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Not found */
404: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Someone changed it at the same time: retry */
409: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
/** @description Business rule (e.g. a transition the workflow forbids) */
422: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorDto"];
};
};
};
};
GitController_receive: {
parameters: {
query?: never;
header?: never;
path: {
/** @description Project id or key */
project: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["GitDeliveryResultDto"];
};
};
/** @description Unknown project, integration off or bad signature */
403: {
headers: {
[name: string]: unknown;
};
content?: never;
};
};
};
}