From 01e8e07f62f2042671ff9b57c32780c4fd21cae2 Mon Sep 17 00:00:00 2001 From: Vladi Date: Wed, 19 Aug 2020 19:04:25 +0200 Subject: [PATCH] Revert legacy Jira config. Add basic support for it. --- Config.groovy | 5 ++++- scripts/exportJiraIssues.gradle | 34 ++++++++++++++++++++++++++++++++- template_config/Config.groovy | 3 +++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Config.groovy b/Config.groovy index c35e9ab11..3d5741e3d 100644 --- a/Config.groovy +++ b/Config.groovy @@ -187,7 +187,10 @@ jira.with { dateTimeFormatOutput = "dd.MM.yyyy HH:mm:ss z" // i.e. 24.07.2020 09:02:40 CEST // the label to restrict search to - label = + label = 'label1' + + // Legacy settings for Jira query. This setting is deprecated & support for it will soon be completely removed. Please use JiraRequests settings + jql = "project='%jiraProject%' AND labels='%jiraLabel%' ORDER BY priority DESC, duedate ASC" // Base filename in which Jira query results should be stored resultsFilename = 'JiraTicketsContent' diff --git a/scripts/exportJiraIssues.gradle b/scripts/exportJiraIssues.gradle index 33a784a58..543a7c00b 100755 --- a/scripts/exportJiraIssues.gradle +++ b/scripts/exportJiraIssues.gradle @@ -63,6 +63,11 @@ task exportJiraIssues( def jiraRequests = config.jira.requests + if (config.jira.jql) { + logger.warn(">>>Found legacy Jira requests. Please migrate to the new Jira configuration ASAP. Old config with jql will be removed soon") + writeAsciiDocFileForLegacyConfiguration(jira, headers, config.jira) + } + jiraRequests.each {rq -> logger.quiet("Request to Jira API for '${rq.filename}' with query: '${rq.jql}'") @@ -177,4 +182,31 @@ task exportJiraIssues( } } } -//end::exportJiraIssues[] + +// This method can be removed when support for legacy Jira configuration is gone +def writeAsciiDocFileForLegacyConfiguration(def restClient, def headers, def jiraConfig) { + def resultsFilename = "${jiraConfig.resultsFilename}_legacy.adoc" + + def openIssues = new File(targetDir, "${resultsFilename}") + openIssues.write(".Table {Title}\n", 'utf-8') + openIssues.append("|=== \n") + openIssues.append("|Key |Priority |Created | Assignee | Summary\n", 'utf-8') + def legacyJql = jiraConfig.jql.replaceAll('%jiraProject%', jiraProject).replaceAll('%jiraLabel%', jiraLabel) + println ("Results will for legacy query ${legacyJql} will be saved in '${resultsFilename}' file") + + restClient.get(path: 'search', + query: ['jql' : jiraConfig.jql.replaceAll('%jiraProject%', jiraProject).replaceAll('%jiraLabel%', jiraLabel), + 'maxResults': 1000, + 'fields' : 'created,resolutiondate,priority,summary,timeoriginalestimate, assignee' + ], + headers: headers + ).data.issues.each { issue -> + openIssues.append("| ${jiraRoot}/browse/${issue.key}[${issue.key}] ", 'utf-8') + openIssues.append("| ${issue.fields.priority.name} ", 'utf-8') + openIssues.append("| ${Date.parse(jiraConfig.dateTimeFormatParse, issue.fields.created).format(jiraConfig.dateTimeFormatOutput)} ", 'utf-8') + openIssues.append("| ${issue.fields.assignee ? issue.fields.assignee.displayName : 'not assigned'}", 'utf-8') + openIssues.append("| ${issue.fields.summary} ", 'utf-8') + } + openIssues.append("|=== \n") +} +//end::exportJiraIssues[] \ No newline at end of file diff --git a/template_config/Config.groovy b/template_config/Config.groovy index b7c84ef2e..d6170d066 100644 --- a/template_config/Config.groovy +++ b/template_config/Config.groovy @@ -198,6 +198,9 @@ jira.with { // the label to restrict search to label = + // Legacy settings for Jira query. This setting is deprecated & support for it will soon be completely removed. Please use JiraRequests settings + jql = "project='%jiraProject%' AND labels='%jiraLabel%' ORDER BY priority DESC, duedate ASC" + // Base filename in which Jira query results should be stored resultsFilename = 'JiraTicketsContent'