Skip to content

Instantly share code, notes, and snippets.

@t3knoid
t3knoid / JenkinsPipeline_getJiraIssuesList.groovy
Created February 2, 2018 16:15
Jenkins pipeline script that will create an HTML formatted list of Jira issues
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
@t3knoid
t3knoid / JenkinsPipeline_updateJira.groovy
Last active May 31, 2022 15:27
Jenkins pipeline script to update Jira fields example
/**
* Updates Jira Fixed in build field with the build number and adds a comment in each related Jira issue
* This requires the Jenkins JIRA Pipeline Steps plugin https://jenkinsci.github.io/jira-steps-plugin/getting-started/
* @param build Build number that will be entered in the "Fixed in Build" Jira field
*/
def updateJira(build) {
def jiraServer = 'JIRA-PROD' // Define a Jira server entry in the Jenkins Jira Steps configuration named JIRA-PROD
def jiraIssues = jiraIssueSelector(issueSelector: [$class: 'DefaultIssueSelector'])
jiraIssues.each { issue ->
jiraAddComment comment: "{panel:bgColor=#97FF94}{code}Code was added to address this issue in build ${build}{code} {panel}", idOrKey: issue, site: jiraServer