Example scripts
To homepage
Confluence

Add Label to Outdated Pages Job
App in script

ScriptRunner For Confluence
by Adaptavist
Compatibility

Confluence (7.15 - 8.6)

ScriptRunner For Confluence (7.10.0)
Language |
groovy
package examples
import com.atlassian.confluence.labels.Label
import com.atlassian.confluence.labels.LabelManager
import com.atlassian.sal.api.component.ComponentLocator
import static com.atlassian.confluence.labels.Namespace.GLOBAL
import com.onresolve.scriptrunner.parameters.annotation.ShortTextInput
@ShortTextInput(label = 'Label', description = 'Label to add to pages')
String labelName
assert labelName
def labelManager = ComponentLocator.getComponent(LabelManager)
def label = labelManager.getLabel(labelName) ?: labelManager.createLabel(new Label(labelName, GLOBAL))
hits.each { page ->
if (!page.labels*.name.contains(labelName)) {
labelManager.addLabel(page, label)
}
}
Having an issue with this script?
Report it here