Skip to content

Commit

Permalink
Revert legacy Jira config. Add basic support for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoks committed Aug 19, 2020
1 parent 72abbe3 commit 01e8e07
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
34 changes: 33 additions & 1 deletion scripts/exportJiraIssues.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}'")

Expand Down Expand Up @@ -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[]
3 changes: 3 additions & 0 deletions template_config/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 01e8e07

Please sign in to comment.