I have a request to add a certain category/label to a bunch of Spaces. I need a script for that since there are more than 100 Spaces. I manage to get Category from one space, but I don't know how to add a category through Groovy script.
Here are the code for getting a Category, note maybe some imports are obsolete since I was trying different things
//start
import com.atlassian.confluence.pages.Page
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.labels.Label
import com.atlassian.confluence.labels.LabelManager
import com.atlassian.confluence.spaces.SpaceManager
def labelManager = ComponentLocator.getComponent(LabelManager)
def newLabel = "myLabel"
return labelManager.getTeamLabelsForSpace("spaceCode")
//end
This code returns a label, but what method adds it. I found addLabel method but don't know how to use it.