Skip to content

pwillis-els/fix-atlassian-links

Repository files navigation

About

Python script to fix (usually by search/replace) the HTTP[S] links in Atlassian products like Confluence, Jira, etc.

Install

Local install

  1. Run pip install -e .

Docker build

  1. Run docker build -t fix-atlassian-links:latest .

Usage

Example using Docker

docker run --rm -it fix-atlassian-links \
    --page_id 123456 \
    --search "https://my-old-domain" \
    --replace "https://my-new-domain" \
    --url "https://mycompany.atlassian.net/wiki" \
    --username "[email protected]" \
    --auth_token "3h938h9h98hhr93hqhoq" \
    search-replace-page

Run the installed fix-atlassian-links to see its usage.

usage: fix-atlassian-links [-h] [--url URL] [--title TITLE]
                           [--page_id PAGE_ID] [--username USERNAME]
                           [--auth_token AUTH_TOKEN]
                           [--page_content PAGE_CONTENT] [--search SEARCH]
                           [--replace REPLACE] [--literal] [--read_only]
                           {put-page,search-replace-page,get-page}

The fix-atlassian-links command-line interface to the fix_atlassian_links Python package.

You can pass three environment variables:
   CONFLUENCE_URL       - This is the base URL of the Confluence instance. This is NOT an individual page.
   CONFLUENCE_USER      - The username to connect to Confluence with.
   CONFLUENCE_PASS      - The password or authentiction token to connect to Confluence with.

The 'get-page' action requires the following options:
    --page_id

The 'search-replace-page' action requires the following options:
    --page_id
    --search
    --replace

positional arguments:
  {put-page,search-replace-page,get-page}
                        Choose an action to perform

optional arguments:
  -h, --help            show this help message and exit
  --url URL             Page base URL, default=None
  --title TITLE         The title of a page [to get, create, update]
  --page_id PAGE_ID     ID of page to update
  --username USERNAME   Username for Confluence
  --auth_token AUTH_TOKEN
                        Authentication token or password for Confluence
  --page_content PAGE_CONTENT
                        New page content (not currently used)
  --search SEARCH       Search regular expression (or literal search text)
  --replace REPLACE     Replacement text for search
  --literal             Only do literal search/replace, no regular expression
  --read_only           Do not perform any write actions

About

Python tool to fix broken links in Atlassian products

Resources

License

Stars

Watchers

Forks

Packages

No packages published