Updating Confluence URL links using CLI Tool

Hello,

We changed the URL to our confluence server and I wanted to update any hard links to the old URL with the new URL using the CLI tool. However I am running into problems.

I tried using the example on this page:
https://bobswift.atlassian.net/wiki/display/CSOAP/How+to+globally+search+and+modify+content


It works for me, however, when I try to edit all the spaces, it only edits the test page I created. So I'm not sure what I am doing wrong. This is the command I am running:

confluence --action runFromContentList --search "\"https://confluence.in.here.com\"" --space @all --common "--action modifyPage --id @pageId@ --findReplace \"https://wiki.ad.navteq.com/confluence#https://confluence.in.here.com\" --special \" #\" "



When I use the command to just "getContentList" it only returns the page I just created as a test as well as a different page in the same space:

C:\Users\lestrell\Desktop\atlassian-cli-3.8.0>confluenceprod --action getContent
List --search "\"https://confluence.in.here.com\""

2 results in list

"Id","Type","Title","URL","Excerpt"
"214302939","page","change","https://confluence.in.here.com/display/BSGS/change"
," ... aaa https://confluence.in.here.comá bbbb á ccc Testingá dddd"
"113934408","page","html macro","https://confluence.in.here.com/display/BSGS/htm
l+macro"," ... font color=""red"" size=""3""><strong>Wiki URL has changed to ""h
ttps://confluence.in.here.com"". <a href=""https://confluence.in.here.com/displa
y/HELP/Upgradeto5.5andMigrationtoaHERE.comURL""> Click here</a> for more informa
tion.</strong></font> </center> <center ... "



So, I'm not sure what I am doing wrong. Can anyone help?

2 answers

1 accepted

Search uses Confluence text search, so you can go to the UI and conduct the same search. See how many hits you get? I suspect you really want to find links that will be broken with the change. There probably isn't a way to subset pages that have the link. So, that means doing all pages.

OK, when I go to the UI I only get one page result as well. Yes, I wanted to udpated any broken link that was in any and all pages...I guess that is not possible?

No, it just means it will be slow doing the change for all pages. Perhaps do a space at a time. Same approach as before, but not using search. Instead, use runFromPageList with --space XXX. This will go through each page in the space and attempt the findReplace. If nothing is found, the page should not be updated (verify this on a few of your pages first if you like). It takes a lot longer since each page must be downloaded.

Great, thank you so much for your help Bob. I appreciate it.

I've been trying to complete this same task with no results. It is basically the same step listed here as exmaple 1:

https://bobswift.atlassian.net/wiki/display/CSOAP/How+to+globally+search+and+modify+content

confluence.sh --action runFromPageList --space "RDAISC" --common "--action modifyPage --id @pageId@ --findReplace \"http://wiki.ad.navteq.com/confluence#http://confluencedev.in.here.com\" --special \" #\" "

The interesting thing is that I can get this to replace any normal text on a page, but it will not alter the URL in anchor tags. Any thoughts?

Take a look at an example page's storage format and verify the text matches your find string. Next simplify and run just against the example page and use --debug on the action and see if that helps you see what is going on. Open an issue if you have problems and provide the log.

OK, when I go to the UI I only get one page result as well. Yes, I wanted to udpated any broken link that was in any and all pages...I guess that is not possible?

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 ...

1,005 views 23 13
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