// Assuming issue.fields contains the sprint details, which is a list of sprint objects
def sprintDetails = issue.fields[sprintFieldId]
def isSprintActive = false
def sprintName = null
if (sprintDetails) {
for (sprint in sprintDetails) {
if (sprint.state == "active") {
isSprintActive = true
sprintName = sprint.name
break
}
}
}
// Assuming you have a method to make an HTTP POST request
def response = post(webhookUrl)
.header('Content-Type', 'application/json')
.body(msg)
.asString()
println(response)
}
}
} else {
if (projectKey != 'TU') {
println("Project key does not match.")
} else if (!isSprintActive) {
println("Sprint is not active.")
} else if (!office.contains("Bangalore") || !office.contains("Hyd")) {
println("Office not in the specified list.")
}
}
def issueKey = issue.key def office = issue.fields.customfield_10246?.value?.join(", ") def projectKey = issue.fields.project.key def sprintFieldId = 'customfield_10020'
// Assuming issue.fields contains the sprint details, which is a list of sprint objects def sprintDetails = issue.fields[sprintFieldId] def isSprintActive = false def sprintName = null
if (sprintDetails) { for (sprint in sprintDetails) { if (sprint.state == "active") { isSprintActive = true sprintName = sprint.name break } } }
println("Is sprint active: ${isSprintActive}") println("Office: ${office}")
if (projectKey == 'TU' && isSprintActive && office.contains("Bangalore") && office.contains("Hyd")) { // Assuming you have the changelog object available for (item in changelog.items) { if (item.field == "Sprint") { def webhookUrl = 'https://hooks.slack.com/services/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' def msg = [ text: """${sprintName} raised a ticket on PSO that we think should be handled by @bs2: https://tideaccount.atlassian.net/servicedesk/customer/portal/20/${issue.key} - ${issue.fields.summary}""" ]
} else { if (projectKey != 'TU') { println("Project key does not match.") } else if (!isSprintActive) { println("Sprint is not active.") } else if (!office.contains("Bangalore") || !office.contains("Hyd")) { println("Office not in the specified list.") } }