fix(Jira Trigger Node): Fix Jira webhook subscriptions on Jira v10+ (#14333)

This commit is contained in:
Elias Meire
2025-04-02 12:49:25 +02:00
committed by GitHub
parent 8abbc304f0
commit cd212e4f78
4 changed files with 343 additions and 13 deletions

View File

@@ -11,6 +11,8 @@ import type {
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
import type { JiraServerInfo, JiraWebhook } from './types';
export async function jiraSoftwareCloudApiRequest(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
endpoint: string,
@@ -122,8 +124,9 @@ export function eventExists(currentEvents: string[], webhookEvents: string[]) {
return true;
}
export function getId(url: string) {
return url.split('/').pop();
export function getWebhookId(webhook: JiraWebhook) {
if (webhook.id) return webhook.id.toString();
return webhook.self?.split('/').pop();
}
export function simplifyIssueOutput(responseData: {
@@ -266,3 +269,22 @@ export async function getUsers(this: ILoadOptionsFunctions): Promise<INodeProper
return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1;
});
}
export async function getServerInfo(this: IHookFunctions) {
return await (jiraSoftwareCloudApiRequest.call(
this,
'/api/2/serverInfo',
'GET',
) as Promise<JiraServerInfo>);
}
export async function getWebhookEndpoint(this: IHookFunctions) {
const serverInfo = await getServerInfo.call(this).catch(() => null);
if (!serverInfo || serverInfo.deploymentType === 'Cloud') return '/webhooks/1.0/webhook';
// Assume old version when versionNumbers is not set
const majorVersion = serverInfo.versionNumbers?.[0] ?? 1;
return majorVersion >= 10 ? '/jira-webhook/1.0/webhooks' : '/webhooks/1.0/webhook';
}