confluence labels remain after cli reportes removal

Hi all,

I have a script (shown below) that traverses all pages in a space and removes labels. This works great for some cases but not all. If I create a new space, add pages and labels the script cleans them nicely. If I use on of my javadoc spaces which has 4000+ labels the script reports label removal, but the labels remain.

Example Output:

PAGE: my page
LBLS: FooBar
Labels: 'FooBar ' were removed from item: 'my page' from space: 'javadoc'
remaining LBLS: FooBar

I exported the space to xml and looked at the labels. I see nothing special about them. I am concerned by the trailing space on the labels output. I tried executing the command manually and I get the same result. I'm not sure what is blocking the removal.

Please let me know if you see an issue that I'm missing. I'm going to dig into the source code.

Thanks

Peter

#!/usr/bin/env bash

function listLabels
{
	space=$1
	page=$2
	./confluence.sh -a getLabelList --space $space --title "$page"|egrep -v 'labels in list'|sed ':a;N;$!ba;s/\n/,/g;s/,$//'
}

function listPages
{
	space=$1
	echo Creating PageList ${space}.pages ...
	./confluence.sh -a getPageList --space $space |egrep -v 'pages in list' > ${space}.pages
	echo PageList Complete...
}

function removeLabelsFromPage 
{
	space=$1
	page=$2

	labels=`listLabels $space "$page"`
	echo PAGE: $page
	echo LBLS: $labels
	./confluence.sh -a removeLabels --space $space --title "$page" --labels $labels
        echo remaining LBLS: `listLabels $space "$page"`
	echo "-----------"
}

function removeLabelsFromSpacePages
{
	space=$1
	pageListFile=$2

	while read line
	do 
	removeLabelsFromPage $space "$line"
	done < ${pageListFile}
}

## ---------------------
## MAIN
## ---------------------
space=$1
listPages $space
removeLabelsFromSpacePages $space ${space}.pages

1 answer

1 accepted

Probably you are running into an historical inconsistency in the CLI. Confluence CLI uses: Comma separated list of labels. JIRA CLI uses a blank separated list (which is better in this case). Confluence CLI should be changed to support both, but for now use a comma. Please open an issue for the change.

Thanks Bob, but it fails on a list on one as well. There must be something special about the label in question. 'HasFields'. Is the repository in bit bucket? I found cli, but not confluence cli. I want to take a stab at debugging this one. Peter

Please open an issue and provide an example of the CLI actions run using -v parameter. The bitbucket repository is now private, you will have to use the older version source zip.

Ah figured out the problem. My space generator takes javadoc and builds a space xml out of it. It splits the package names into labels but doesn't track and re-use labels. So, I have 200 + "com" labels. I think this is why I ran into the problems. I fixed the generator code and I think Atlassian fixed import so duplicate labels are no longer a problem.

Thanks for the comments. I think this is self manufacturered.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

899 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you