Created
February 2, 2018 16:15
-
-
Save t3knoid/cb09da16b042bb55ddda370615d73c3e to your computer and use it in GitHub Desktop.
Jenkins pipeline script that will create an HTML formatted list of Jira issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getJiraIssueList() { | |
/** | |
* Returns an HTML formatted list of Jira issues related in the build. | |
* This requires the Jenkins JIRA Pipeline Steps plugin https://jenkinsci.github.io/jira-steps-plugin/getting-started/ | |
* @param None | |
* @return An HTML string containing Jira issues | |
*/ | |
def jiraServer = 'JIRA-PROD' // Define a Jira server entry in the Jenkins Jira Steps configuration named JIRA-PROD | |
def jiraURL = "http://my.jiraserver.com:8080" // Define the Jira URL | |
def jiraIssues = jiraIssueSelector(issueSelector: [$class: 'DefaultIssueSelector']) // Get all related Jira issues in a list | |
def issueList = "<h2>No changes since last build.</h2><ul>" | |
if (jiraIssues.size() != 0) { | |
issueList = "<h2>List of Changes</h2><ul>" | |
jiraIssues.each { issueID -> | |
def issue = jiraGetIssue idOrKey: issueID, site: jiraServer // Retrieves the Jira issue | |
def summary = issue.data.fields.summary.toString() // Retrieves the summary field | |
issueList = issueList.concat("<li><a href=\"${jiraURL}/browse/${issueID}\">${issueID} : ${summary}</a></li>") | |
} | |
issueList = issueList.concat("</ul>") | |
} | |
return (issueList) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment