You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
hi
i have jira auto create tickets with summary as below
[DEPLOYMENT] test_putinlabels uuuuu
I want to update a labels with the text test_putinlabels.
can we do this as a post function and if yes what is the code
Yes, you can do that with a script.
The snippet I have is
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
def user = ComponentAccessor.jiraAuthenticationContext.getUser()
LabelManager labelManager = ComponentAccessor.getComponent(LabelManager)
def labels = labelManager.getLabels(issue.id).collect{it.getLabel()}
labels += 'new_label'
labelManager.setLabels(user.getDirectoryUser(),issue.id,labels.toSet(),false,false)
That code just sets the labels, you'll need to code "issue.summary to list of labels to add" for yourself.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kaushal,
Hopefully the script Nic provided worked out for you. If so please mark his answer as Accept Solution so others may benefit from the solution as well!
Cheers,
Branden
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
i dont understand how to get the information for the summary and add it to the label. not dont much coding before. is there any guides i can follow to help with this part
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi all
i figured this out with the help of someone but can someone explain why we have to use print for this to work my code is below
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
def user = ComponentAccessor.jiraAuthenticationContext.getUser()
def summary = issue.summary
print(summary)
if (summary.startsWith("[test]"))
{
LabelManager labelManager = ComponentAccessor.getComponent(LabelManager)
def labels = labelManager.getLabels(issue.id).collect{it.getLabel()}
def newlabel = summary.split(" ")[1]
print(newlabel)
labels += newlabel
labelManager.setLabels(user.getDirectoryUser(),issue.id,labels.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.
Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.