CLI: "copyPage" does not copy childpages when used in "runFromPageList"

Franz Steindl February 1, 2019

CopyPage on a single Pagenode works fine. Also the children get copied.

./confluence.sh -s serverurl -u userid -p @ --action copyPage --space "~userid" --title "Page 2019" --options applyFindReplaceOnTitles   --findReplace 2019:2020  --newTitle @title@ --parent @source --mergePermissions --descendents --copyAttachments --copyLabels --copyPermissions

Running the command for a list of pages (runFromPageList) will copy only the listed pages but not the children of each page.

./confluence.sh -s serverurl -u userid -p @ --action runFromPageList  --space "~userid"  --regex ".*,.*Pages 2019"  --common "--action copyPage --id @pageId@ --options \"applyFindReplaceOnTitles\"   --findReplace \"2019:2020\"  --newTitle \"PREFIX-@title@\" --parent @source --mergePermissions --descendents --copyAttachments --copyLabels --copyPermissions"

A warning is displayed:

Warning: request to copy children or descendents ignored as they would not have a unique name in the space. Consider using @title@ replacement.

How can I avoid the warning and getting the descendents copied?

 

4 answers

0 votes
Deleted user February 26, 2019

Hi franz steindl,

Thanks for providing us the detailed information on the requirement which you are trying to achieve. If you want to copy the hierarchy, you are required to mention the parent page name/id to which the copy of the pages needs to be placed under.

As per the example which you have provided in your comment, if you would like to copy the page hierarchy "parent with 2 children - year 2119" under the parent A level 2 then you need to mention the parent parameter for copyPageHierarchy action as shown below.

--action runFromPageList --space "TESTSPACE1" --title "parent with 2 children - year 2119" --common "--action copyPageHierarchy --space "TESTSPACE1" --id @pageId@  --parent "Alevel2" --options "titlePrefix=new-"  --options "titleFind=2119" --options "titleReplace=2120" --descendents"

Similarly, if you would like to copy another hierarchy, for example, "parent with 2 kids - year 2119" under the parent "A Stage 1 (not homepage)" then you need to mention the parent parameter for copyPageHierarchy action as shown below. Unfortunately, you will not be able to use regex in both the cases as a parent to which they need to be linked are different (in this case "Alevel2" and "A Stage 1 (not homepage)".

--action runFromPageList --space "TESTSPACE1" --title "parent with 2 children - year 2119" --common "--action copyPageHierarchy --space "TESTSPACE1" --id @pageId@  --parent "A Stage 1 (not homepage)" --options "titlePrefix=new-"  --options "titleFind=2119" --options "titleReplace=2120" --descendents"

Please see the below image for the outcome of the above commands.

image-copyHeirarchy.png

Thanks,

Raja

Franz Steindl February 28, 2019

Hello Raja,

thx for you attemps.

So let's sum up.

copyPageHierachy in combination with runfrompagelist isn't usefull due to missing flexible parent parameter.
copyPage in combination with runfrompagelist, including the childpages, copies childpages on the wrong hierachical position too.

copyPage in combination with runfrompagelist, including only the parent pages, would be the solution. But this feature is buggy. Can I find it on your bug list?

In the meantime, is there another option like creating a runfrompagelist file with all the needed information and fire a 2nd comand?

Thank you in advance.

Regards,

Franz

Deleted user March 7, 2019

To conclude, we have raised a request CSOAP-1024 with our development team.

 

Thanks,

Raja

0 votes
Deleted user February 18, 2019

 franz steindl,

We executed the below command to copy pages along with their child pages from a space, now you can see the parent and child pages are following the exact hierarchy.

Please use the below command and let us know if it works fine for you.

java -jar `dirname $0`/lib/confluence-cli-8.1.0.jar --debug --action runFromPageList --space “TESTSPACE” --title “TestSpace Home” --common “--action copyPageHierarchy --space “TESTSPACE” --id @pageId@  --parent @home --options “titlePrefix=new-”  --options “titleFind=2019” --options “titleReplace=2020" --descendents” --server http://localhost:8606 --user xxxx --password xxxxx “$@”

Please see the below screenshot for the same.
image.png

Regards,
Raja

Franz Steindl February 19, 2019

Hi Raja,

your new workaround works only when you know the new parent of the pages before. In your sample it's "parent @home". In my case I don't know the new position. It should simple be on the same hierachical level as the pages to copy.

Nevertheless when using copyPageHierachy no other needed options like "findReplaceRegex" are working.

So what about fixing the original reported bug?

Best regards,

Franz

Deleted user February 20, 2019

Hi franz steindl,

We have given n number of trails on different confluence spaces and able to copy pages along with child pages. 

As per your requirement, Parent page title needs to be modified/replaced when it gets copied. If you use "parent @home" option, that references the home page of the space. We are able to see the newly copied parent page along with child pages created in the same hierarchy. If it is not matching with your requirements, do let us know the same.

Regards,

Raja

Franz Steindl February 25, 2019

Hi Raja,
thx. I had a great weekend. I hope you too.
In the meantime I have got some new information.

First, your example with not allowed quotation marks was a little bit misleading. So it took me some time to figure it out.

Next, I created a separate test space to evalute your workaround again.

Please see the starting space structure and the resulting one in the attachments.

Here is my customized command:

./confluence.sh -s server_url -u steindl -p @ --action runFromPageList --space 'Testspace' --regex "parent.* - year 2119" --descendents --continue --common "--action copyPageHierarchy --space Testspace --id @pageId@ --parent @home --options \"titlePrefix=new-\" --options \"titleFind=2119\" --options \"titleReplace=2120\" --descendents" --debug &> $(date +%Y-%m-%d_%H%M%S)_debug.log

Additionally, I have to say that 2 pages within the tree should be copied with all their children, but I had to execute the command 2 times the see the final result. The debug logs will be attached.

Finaly, the copied Pages (and their children) are directly placed under the home-page. My source pages are some level deeper. Is there an option to copy them on the same structure level (like siblings)?

Further more, I had to take care just to have only the parent pages in the pagelist. Otherwise "copyPageHierarchy" would try to copy them twice. One time because referenced in the pagelist and 2nd time as a child when the parent gets copied. But this could be done by the regex.

For confidentiality, I did some anonymization in the logs.

Best regards,
Franz

0 votes
Deleted user February 6, 2019

Hello Franz Steindl,

Thanks for providing the logs. To copy parent and descendant pages, please modify the actions as given below

1. For a single Page node

--action copyPage --space "spacename" --title "Page 2019" --options applyFindReplaceOnTitles --findReplace 2019:2020 --newTitle "copied-@title@" --parent @source --mergePermissions --descendents --copyAttachments --copyLabels --copyPermissions

2. For a list of pages

--action runFromPageList  --space "spacename" --regex ".*2019.*" --descendents --continue --common "--action copyPage --id @pageId@ --options \"applyFindReplaceOnTitles\" --parent @source  --findReplace \"2019:2020\"  --newTitle \"new-@title@\" --mergePermissions --copyAttachments --copyLabels --copyPermissions"

Please check and let us know the outcome. If you are seeing any more errors, provide debug logs for each of the action commands separately.

Thanks,
Raja

Franz Steindl February 11, 2019

Hello Raja,

Thanks for your prompt reply.

Your offered workaround copies all pages but due to having the child pages in the page list the copied children are in the wrong hierachical position. So the parentage gets lost. Please see the attached screenshots.

Best regards,

Franz

Screen Shot 2019-02-11 at 10.09.50.png

Tree before copying:Screen Shot 2019-02-11 at 10.10.39.png

0 votes
Deleted user February 5, 2019

Hello Franz Steindl,

We are able to reproduce the issue, to dig more into this we need to have a look into your debug logs. Can you please append --debug to the action command and share the log file with us. Please login to our portal here and share the files.

Regards,

Raja

Franz Steindl February 5, 2019

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events