If you prefer keeping your documentation in Git, love writing in Markdown, but need to publish it in Confluence, this tool is for you.
Confluence Updater renders your Markdown files into HTML and uploads them to a specified page in your Confluence Cloud instance. The tool assigns each page a SHA label based on its content. If the SHA remains unchanged since the last update, the page is skipped.
With this tool, you can automate documentation uploads in a CI/CD pipeline. Check out the setup guide on my blog.
Confluence Cloud requires personal access tokens for authentication.
Generate an API token at: Atlassian API Tokens.
The tool applies a label using the local part of the email associated with the token. For example, [email protected] will have the label pa-token/patrick applied. This labeling system helps track and replace tokens when necessary.
By setting the superscriptHeader property in the configuration, you can quickly locate Confluence pages linked to a specific repository.
The tool searches for a confluence-updater.yaml (example here) file in the current directory. This file defines which Markdown files to render and their corresponding Confluence page IDs.
Note: You must manually create the Confluence page and obtain its ID beforehand.
Run the following command:
confluence-updater -u [email protected] -s <api-token> --fqdn https://your-domain.atlassian.netAlternatively, use environment variables:
export [email protected]
export CU_SECRET=your-api-token
export CU_FQDN=https://your-domain.atlassian.net$ confluence-updater
INFO Successfully updated page. id="728383651" title="Kubernetes Install Guide" path="./kubernetes-install.md" sha="6b8b051c"
INFO No changes to page, skipping. id="729133252" title="Grafana Install Guide [v.61]" path="./grafana-install.md" sha="fa3d0cdd"Usage: confluence-updater [OPTIONS] --user <USER> --secret <SECRET> --fqdn <FQDN>
Options:
-u, --user <USER> Confluence user to login with [env: CU_USER=]
-s, --secret <SECRET> The token/secret to use. https://id.atlassian.com/manage-profile/security/api-tokens [env: CU_SECRET=]
--fqdn <FQDN> The fully qualified domain name of your Atlassian Cloud. [env: CU_FQDN=]
-c, --config-path <CONFIG_PATH> The path to the config file. [env: CU_CONFIG_PATH=] [default: ./confluence-updater.yaml]
-l, --label <label> Add a label to all updating pages. Can be used multiple times.
--log-level <LOG_LEVEL> Log Level. [env: CU_LOG_LEVEL=] [default: info] [possible values: trace, debug, info, warn, error]
-h, --help Print help
-V, --version Print versionA prebuilt container image is available. You can run it with the following command:
docker run --rm ghcr.io/kerwood/confluence-updater:latest \
-u [email protected] \
-s <api-token> \
--fqdn https://your-domain.atlassian.netA Dagger module is also available to integrate Confluence Updater into your own workflow.
You can use the module in two ways:
- Install it into your own Dagger module
- Use it as a blueprint like the example below.
export TOKEN=<your-atlassian-token>
dagger -c 'with-fqdn https://your-domain.atlassian.net | with-user [email protected] | with-token env://TOKEN | run-update'More information can be found here.
Confluence Updater generates a SHA hash of the content and stores it on the Confluence page as a label. On each run, it checks for changes using the SHA and updates the page only if modifications are detected.
The following elements are included in the SHA, meaning any changes to them will trigger a page update:
- Markdown file content.
- Override title.
- Superscript header.
- Labels.
- Read Only boolean
Convert relative Markdown file links to Confluence page links using pid:<page-id>:
[Some link text](./other/file.md "pid:5234523")If the readOnly property is not set at the global and page level configuration, Confluence Updater will not
modify any existing page restrictions. This allows page restrictions to be set manually within Confluence without
being overwritten by Confluence Updater.
- Setting
readOnly: truegrants read-only access to everyone except the access token owner, who will retain write permissions. - Setting
readOnly: falseremoves all user restrictions, effectively making the page editable by anyone in the Confluence space.
Changing this setting will affect the sha label and trigger a page update.
readOnly: true
pages:
- filePath: ./README.md
pageId: 228184928
readOnly: falseMarkdown image links are automatically uploaded as attachments and embedded in the Confluence page.
You can control image alignment by specifying align-left, align-right, or align-center in the alt text.
NOTE: The Confluence API is a bit unstable when it comes to uploading attachments. This is the reason that images are not uploaded asynchronously, the API simply can't handle it.
Some times you will recieve below error for no apparent reason.
ERROR image="images/superscriptheader.png" error=HTTP request, HTTP status server error (500 Internal Server Error)
Add a small superscript header with Markdown support at the top of each page by setting superscriptHeader at the root or page level:
superscriptHeader: This page is sourced from [kerwood/confluence-updater](https://github.com/Kerwood/confluence-updater)
pages:
- filePath: ./README.md
pageId: 228184928
superscriptHeader: Some other superscript headerMarkdown code blocks are converted into Confluence CodeBlock macros with syntax highlighting:
```rust
let x = "hello-world";
```- Set environment variables or use command-line parameters.
- Create a
confluence-updater.yamlfile (example here). - Run the updater:
confluence-updaterExample output:
INFO Successfully updated page. id="728383651" title="Kubernetes Install Guide" path="./kubernetes-install.md" sha="6b8b051c"
INFO No changes to page, skipping. id="729133252" title="Grafana Install Guide [v.61]" path="./grafana-install.md" sha="fa3d0cdd"A GitHub Action is available: Confluence Updater Action.
- name: Confluence Updater
uses: kerwood/confluence-updater-action@v1
with:
fqdn: your-domain.atlassian.net
user: ${{ secrets.USER }}
api_token: ${{ secrets.API_TOKEN }}- Updated crate version in Cargo.toml to correct version.
- Minor dependency updates.
- Fixed format macro's to comply with Clippy.
- Added support for tables.
- Added support for removing page restrictions by setting
readOnly: false. See Read Only - Added support for preserving existing page restrictions by omitting the
readOnlyproperty entirely. See Read Only - Added validation for
fqdn,user, andsecretarguments to ensure values are not quoted, with clear error messages for invalid input. - Changed log level env name from
LOG_LEVELtoCU_LOG_LEVEL.
- Changed the
pa-token:xxxandpage-sha:xxxlabels to use supported characters. (pa-token/xxx,page-sha/xxx) - Added a regex check to all labels. If labes are not valid they will be skipped and a warning will be emitted.
- Added better error logs if FQDN is missing
https://protocol scheme. - Confluence updater now uploads page images before it updates the page.
- Added support for superscript page header. See Superscript Header
- Added support for images. See Image Uploads.
- Added page restriction support. See Read Only.
- Added link replacement. See Link Replacement.
- Personal Access Token label now uses the local part of the email. See Authentication.
- Renamed
shalabel topage-sha. - Removed
urlcrate dependency. - Protocol schema (
https://) is now mandatory in the FQDN parameter. - Fixed #3: indentation issue in code blocks.
- Extracts the top
h1header from Markdown as the Confluence page title. - Added
overrideTitleproperty to specify a custom title. - Switched to
CodeBlockmacro for syntax highlighting. - Replaced
contentproperty withpages. - Removed
contentType. - Switched from
serde_yamltoserde_yml. - Replaced
structoptwithclap. - Switched from
openssltorusttls. - Implemented structured logging using
tracing.


