I am looking to automate a new integration where jira issues are created automatically. The issues have the same text in the description but after the / its a different word. I would like to capture that word and set it as a label.
Has anyone done anything similar to this?
I believe I would be creating a custom post function to accomplish this. Thanks in advance.
Jira server version 7.13.x and Scriptrunner is latest
Here's something I cobbled together in the Script Console that accomplishes what you seek; you should be able to massage it into a post function.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// "issue" is pre-defined in ScriptRunner post script functions, so the following line is unnecessary (just here for testing)
def issue = ComponentAccessor.issueManager.getIssueByCurrentKey("BR-13209")
def desc = issue.description
def slash = desc.indexOf("/")
if(slash >= 0)
{
def label = desc.substring(slash + 1).trim()
ComponentAccessor.getComponent(LabelManager).setLabels(user, issue.id, [label].toSet(), false, false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.