Introduction

conflcmd is a simple command-line tool that allows one to manage various Confluence content from the command line. conflcmd uses the REST API (Confluence 6.x).

Usage

usage: conflcmd [<options>] <serverurl> <cmd> [<args>]

Manage content on Confluence site. Unless indicated, if <path> is
"-", input is read from stdin.

Configuration files:
~/.conflcmd/main.conf
                    Main configuration.
~/.conflcmd/creds.conf
                    Credentials-only configuration. Note: should
                    only be readable by user.

Common options:
-p                  Load password from configuration file.
-P                  Ask for password.
-u <username>       Account to use.

Commands:
add-attachment <spacekey> <pagename> <attachmentname> <path> <comment>
    Add attachment.

create-page <spacekey> <parentpagename> <pagename> <path>
    Create page. Set parentpagename to "" to create top-level page.

delete-attachment <spacekey> <pagename> <attachmentname>
    Delete attachment.

delete-page <spacekey> <pagename>
    Delete page.

delete-page-version <spacekey> <pagename> <versionrange>
    Delete page versions (from page history). Version range is
    inclusive and takes the form: <first>[-<last>].

get-attachment <spacekey> <pagename> <attachmentname>
    Get attachment.

get-page <spacekey> <pagename>
    Get page contents.

get-page-version-count <spacekey> <pagename>
    Get count of page versions (latest included).

get-page-view <spacekey> <pagename>
    Get rendered page contents.

list-attachments <spacekey> <pagename>
    List page attachments.

list-pages <spacekey>
    List pages.

list-spaces
    List space keys.

update-attachment <spacekey> <pagename> <attachmentname> <path> <comment>
    Update existing attachment.

update-page <spacekey> <pagename> <path> <comment>
    Update existing page.

Configuration

All configuration files are under ~/.conflcmd. The files are:

Ideally, the ~/.conflcmd directory should be user-readable only.

creds.conf

The creds.conf file is meant to hold credentials information that should be kept "secure".

[<sectionname>]
url = <server url>
username = <username>
password = <password>

Note: At the moment, the password is kept in clear text. So, make sure to keep that file user-readable only.

Examples

Security

If access is restricted, use the -u to pass username and either -P, or better, -p . This is usually required to create, delete, and update.

With -P, a password will be asked for interactively. With -p, the password will be looked up in the configuration files.

For the creds.conf file:

[localhost]
url = https://localhost/confluence
username = john
password = 1234

Notes:

Listing and Getting

List pages in space "TEST":

conflcmd https://localhost/confluence list-pages TEST

Get page contents in space "TEST":

conflcmd https://localhost/confluence get-page TEST Test

Get rendered page contents in space "TEST":

conflcmd https://localhost/confluence get-page-view TEST Test

Get number of page versions:

conflcmd https://localhost/confluence get-page-version-count TEST Test

Creating and Updating

Create a page in space "TEST":

conflcmd -u john -P https://localhost/confluence create-page TEST "" "Test2" test.html

Notes:

Create a page as a child of another in space "TEST":

conflcmd -u john -P https://localhost/confluence create-page TEST "Test2" "Test3" test.html

Update page "Hello" content in space "TEST":

conflcmd -u john -P https://localhost/confluence update-page TEST Hello hello.html ""

Notes:

Update page using credentials in configuration file:

conflcmd -u john -p https://localhost/confluence update-page TEST Hello - ""

Notes:

Update page "Hello" content in space "TEST" from stdin:

echo "<h1>Hello</h1><p>Hey there!!!</p>" | conflcmd -u john -p https://localhost/confluence update-page TEST Hello - ""

Update attachment on "Hello" page in space "TEST":

conflcmd -u john -p https://localhost/confluence update-attachment TEST Hello report.pdf new_report.pdf ""

Notes:

Deleting

Delete an attachment:

conflcmd -u jdm -p https://localhost/confluence delete-attachment TEST Hello report.pdf

Delete a page:

conflcmd -u jdm -p https://localhost/confluence delete-page TEST Hello

Notes:

Delete a page version:

conflcmd -u jdm -p https://localhost/confluence delete-page version TEST Hello 1-10

Note:


Ⓒ 2023 expl.info | Powered by rudiweb.