Hello community,
I wrote one listner script but I am getting error could you please help me out where I am getting error.
import com.atlassian.jira.component.ComponentAccessor
// Get necessary Jira components
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
// Define the issue type and affected versions field
def issueTypeToCheck = "sw bug"
def affectedVersionsFieldName = "Affected Versions"
// Retrieve the issue
def issue = event.issue
// Check if the issue type is "sw bug"
if (issue.issueType.name == issueTypeToCheck) {
// Get the affected versions field
def affectedVersionsField = customFieldManager.getCustomFieldObjects(issue).find { it.name == affectedVersionsFieldName }
// Get the current affected versions
def currentAffectedVersions = issue.getCustomFieldValue(affectedVersionsField) ?: []
// Get the latest release version
def latestReleaseVersion = issue.fixVersions.last()?.name
// Check if the latest release version matches the pattern MP1_A00**
if (latestReleaseVersion && latestReleaseVersion =~ /^MP1_A00/) {
// Add the latest release version to affected versions if it's not already there
if (!currentAffectedVersions.contains(latestReleaseVersion)) {
currentAffectedVersions.add(latestReleaseVersion)
issue.setCustomFieldValue(affectedVersionsField, currentAffectedVersions)
}
} else if (latestReleaseVersion == "MP1_S00") {
// Do nothing if the latest release version is MP1_S00
}
}
Thanks in advance.
Hello @Raju
What error are you getting?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.