// 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 (issuetype != 'story') {
println("issuetype does not match.")
} else if (!isSprintActive) {
println("Sprint is not active.")
} else if (!teamName.contains("PS-Magnetite")) {
println("teamName not in the specified list.")
}
}
def issueKey = issue.key def teamName = issue.fields.customfield_11005?.value?.join(", ") def issuetype = issue.fields.issuetype def sprintFieldId = 'customfield_10015'
// 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("team Name: ${teamName}")
if (isSprintActive && teamName.contains("PS-Magnetite") && issuetype == "story") { // 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: """The following issue has been added to the current sprint https://tideaccount.atlassian.net/${issue.key} by ${event.user.displayName}
""" ]
} } else { if (issuetype != 'story') { println("issuetype does not match.") } else if (!isSprintActive) { println("Sprint is not active.") } else if (!teamName.contains("PS-Magnetite")) { println("teamName not in the specified list.") } }