From a0578b16653c03ca18569a62908f09763b3d6541 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 24 Jul 2024 14:04:05 -0300 Subject: [PATCH] ci: avoid task duplication and add develop label (#32889) --- apps/meteor/reporters/jira.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/apps/meteor/reporters/jira.ts b/apps/meteor/reporters/jira.ts index 706856389003..c9fee4748fe5 100644 --- a/apps/meteor/reporters/jira.ts +++ b/apps/meteor/reporters/jira.ts @@ -68,10 +68,10 @@ class JIRAReporter implements Reporter { console.log(`Sending test result to JIRA: ${JSON.stringify(payload)}`); // first search and check if there is an existing issue - + // replace all ()[]- with nothing const search = await fetch( `${this.url}/rest/api/2/search?${new URLSearchParams({ - jql: `project = FLAKY AND summary ~ '${payload.name}'`, + jql: `project = FLAKY AND summary ~ '${payload.name.replace(/[\(\)\[\]-]/g, '')}'`, })}`, { method: 'GET', @@ -104,6 +104,25 @@ class JIRAReporter implements Reporter { if (existing) { const { location } = test; + if (this.pr === 0) { + await fetch(`${this.url}/rest/api/2/issue/${existing.key}`, { + method: 'PUT', + body: JSON.stringify({ + update: { + labels: [ + { + add: 'flaky_Develop', + }, + ], + }, + }), + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Basic ${this.apiKey}`, + }, + }); + } + await fetch(`${this.url}/rest/api/2/issue/${existing.key}/comment`, { method: 'POST', body: JSON.stringify({ @@ -146,6 +165,7 @@ ${this.run_url} project: { key: 'FLAKY', }, + ...(this.pr === 0 && { labels: ['flaky_Develop'] }), }, };