SourceDocs

Guides / Files from Git

Embed a file from GitHub, GitLab, Bitbucket or Azure DevOps in Confluence Cloud

Copying a README or an architecture document into Confluence works for a week; then the copy is out of date. SourceDocs shows the file itself: paste the link once, and the page follows the branch or tag you chose.

Steps · Which links work · What the file looks like · Bitbucket files in Confluence · Private repositories · Your own Git server · How updates appear · Questions

Steps

  1. Install SourceDocs for Confluence from the Atlassian Marketplace. A Confluence admin does this once for the site.
  2. Open the file in your Git provider's web interface and copy the address from the browser bar. For a README, the repository's main page link is enough.
  3. Edit a Confluence page, type /git and pick SourceDocs: File from Git.
  4. Paste the link and click Preview to check the file, then Save and publish the page.
ProviderExample
GitHubhttps://github.com/org/repo/blob/main/docs/architecture.md
https://github.com/org/repo shows the README
GitHub wikihttps://github.com/org/repo/wiki/Getting-Started
https://github.com/org/repo/wiki shows the Home page (more)
GitLab.comhttps://gitlab.com/group/subgroup/repo/-/blob/main/docs/architecture.md
Bitbucket Cloudhttps://bitbucket.org/workspace/repo/src/main/docs/architecture.md
Azure DevOpshttps://dev.azure.com/org/project/_git/repo?path=/docs/architecture.md&version=GBmain
Your own serverGitLab self-managed or Dedicated, GitHub Enterprise Server and ghe.com, after an admin adds the server

The branch, tag or commit in the link is what the page shows. Use main for "always current" and a tag such as v2.4.0 for documentation that should stay frozen at a release. Branch names with a slash, such as release/2.0, work too. The full list of link shapes is in the documentation.

What the file looks like

SourceDocs picks the rendering from the file type:

A bar above the content shows the provider, path, branch and the time of the last fetch, with a link to the file in the repository.

Bitbucket files in Confluence

Pasting a Bitbucket link into a Confluence page gives you a link to the file, not the file itself: readers have to leave the page, and anything you copy over goes out of date. To show the content of a Bitbucket Cloud file on the page:

  1. In Bitbucket, open the file under Source and copy the address from the browser bar, for example https://bitbucket.org/workspace/repo/src/main/docs/architecture.md. The repository address on its own (https://bitbucket.org/workspace/repo) shows the README.
  2. In Confluence, insert SourceDocs: File from Git, paste the link and click Preview.
  3. For a private repository, a Confluence admin stores one Bitbucket credential on the SourceDocs admin page: a repository or workspace access token with Repositories: Read, or an Atlassian API token with the read:repository:bitbucket scope entered as email:api_token. Bitbucket app passwords no longer work.

Markdown, Mermaid, PlantUML, OpenAPI and source files from Bitbucket render the same way as from any other provider, and the page follows the branch or tag in the link. Bitbucket Data Center is not supported yet.

Private repositories

A Confluence administrator stores one read-only token per provider on the SourceDocs admin page (Confluence Settings → Apps → SourceDocs) and clicks Test. From then on, every macro on the site can show files from the repositories that token can read.

Which token to create for each provider, with the smallest permissions that work, is described under private repositories.

Your own Git server

Companies that run GitLab or GitHub Enterprise themselves can add the server on the admin page. Atlassian then shows its own dialog, and an Atlassian administrator approves the connection to that server. The server must be reachable from Atlassian's cloud over HTTPS. See your own Git server.

How updates appear

SourceDocs fetches the file again at most every 10 minutes, so a merged change shows up on the page shortly after. Refresh on the page fetches the latest version immediately. Fetched files are kept inside your Atlassian site for those 10 minutes and then deleted. With Searchable in Confluence on, saving the macro also stores a plain-text copy of the file in it, so Confluence search finds the page by words inside the file.

Questions

Does Confluence search find the content?

Yes. With Searchable in Confluence on (the default), saving the macro stores a plain-text copy of the file, up to 20,000 characters, so Confluence search finds the page by words inside the file. The copy is refreshed each time the macro is saved; the page itself always shows the current file. Switch the option off for files whose text should not be kept in Confluence.

What happens in PDF and Word export?

Markdown becomes real headings, paragraphs, tables and code blocks, so it paginates like the rest of the page. Diagrams are embedded as vector pictures, OpenAPI becomes printable tables, and each file starts with a "Source" line with the link and the fetch date.

How large can a file be?

Up to 16 MB per file and 1 MB per image. That is enough even for GitHub's own REST API description (13.5 MB). Large files travel compressed, and source files above 500 KB are shown without syntax highlighting so the page stays fast.

What does it cost?

Free for Confluence sites with up to 10 users. Above that, from 0.45 USD per user per month, with a 30-day free trial on the Marketplace.

SourceDocs for Confluence renders Markdown, Mermaid, PlantUML, OpenAPI and code files from GitHub, GitLab, Bitbucket and Azure DevOps. Install it from the Atlassian Marketplace. Read the documentation or write to [email protected].

More guides: Mermaid in Confluence · PlantUML in Confluence · Markdown in Confluence · OpenAPI in Confluence · GitHub wiki to Confluence