The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

CQL Script job - ScriptRunner - Remove Labels

Mike
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 15, 2019

I am looking at options to force remove labels from Confluence pages for archival purposes. I have ScriptRunner for Confluence, and see the CQL script jobs under CQL Escalation scripts. 

Has anyone had success utilizing this method? If so, do you have an example? My goal is to run a CQL: label="noarchive-single" or label="noarchive" on a cron and have the labels removed from those pages. 

 

If not, how are you force removing labels on a schedule? 

 

Notes: Confluence Server 6.13.7 / ScriptRunner 5.5.11

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Putri Nur Dayana Kamarudin
January 12, 2022

Hey Mike, this answer might come a bit late but you can use this example and alter it accordingly :

import com.atlassian.confluence.labels.Label
import com.atlassian.confluence.labels.LabelManager
import com.atlassian.confluence.labels.Namespace
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.pages.PageManager

def pageManager = ComponentLocator.getComponent(PageManager)
def labelManager = ComponentLocator.getComponent(LabelManager)

def labelName = "test"
log.warn(">>> ${labelName}")

def label = labelManager.getLabel(labelName).getId()
labelManager.deleteLabel(label)

  The script above will delete a label by retrieving the label ID. 

I hope this helps!

TAGS
AUG Leaders

Atlassian Community Events