conflcmd - Manage Confluence Content
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
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:
- main.conf - main configuration settings; not used at the moment.
- creds.conf - credentials; should be readable only by the user.
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".
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:
url = https://localhost/confluence
username = john
password = 1234
Notes:
- The url must match the serverurl used in the call to conflcmd.
- The username must match the username used in the call to conflcmd.
Listing and Getting
List pages in space "TEST":
Get page contents in space "TEST":
Get rendered page contents in space "TEST":
Get number of page versions:
Creating and Updating
Create a page in space "TEST":
Notes:
- -u is used to specify the account to use.
- -P tells conflcmd to ask for the password (safer than putting it on the command line).
- Set parentpagename to "" to create a top-level page (i.e., not a child page).
- The content is taken from the test.html file.
Create a page as a child of another in space "TEST":
Update page "Hello" content in space "TEST":
Notes:
- The content is taken from the hello.html file.
- The change comment is empty "".
Update page using credentials in configuration file:
Notes:
- The password is provided via the creds.conf file.
- The server url (https://localhost/confluence) must match a definition (url setting) in the creds.conf file.
Update page "Hello" content in space "TEST" from stdin:
Update attachment on "Hello" page in space "TEST":
Notes:
- Attachment named report.pdf is being updated.
- The content is taken from new_report.pdf.
Deleting
Delete an attachment:
Delete a page:
Notes:
- Attachments will follow the page; i.e., they will be deleted.
Delete a page version:
Note:
- Versions 1 to 10 inclusively are deleted.