Hello,
I am trying to copy the labels on an existing issue to its linked issues (through a certain link).
I am pretty close, but I get an error I'm not sure how to overcome:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.label.LabelManager
import org.apache.log4j.Logger
import org.apache.log4j.Level
def issue = event.issue
def labelManager = ComponentAccessor.getComponent(LabelManager)
def existingLabels = labelManager.getLabels(issue.id).collect{it.getLabel()}
def links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())
def subElements = links.findAll { it.issueLinkType.name.contains('Parent/Child') && it.destinationObject.getProjectObject().getKey() == 'TEST'}
subElements.each { it ->
def sublabelManager = ComponentAccessor.getComponent(LabelManager)
def subexistingLabels = sublabelManager.getLabels(it.getDestinationObject().id)*.label
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
for (eachlabel in existingLabels) {
if (eachlabel && !subexistingLabels*.contains(eachlabel)) {
labelManager.setLabels(loggedInUser, it.getDestinationObject().key, eachlabel, false, false)
}
}
}
The error is:
2019-10-17 07:15:24,744 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2019-10-17 07:15:24,744 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.label.DefaultLabelManager.setLabels() is applicable for argument types: (com.atlassian.jira.user.DelegatingApplicationUser, java.lang.String, java.lang.String, java.lang.Boolean, java.lang.Boolean) values: [uidq5816(uidq5816), TEST-1001, a2b, false, false]
Possible solutions: setLabels(com.atlassian.jira.user.ApplicationUser, java.lang.Long, java.util.Set, boolean, boolean), setLabels(com.atlassian.jira.user.ApplicationUser, java.lang.Long, java.lang.Long, java.util.Set, boolean, boolean)
at Script686$_run_closure3.doCall(Script686.groovy:24)
at Script686.run(Script686.groovy:14)
Any help is appreciated.
Thank you!