Publish to Bitbucket Cloud
Bitbucket Cloud is an Atlassian git hosting service with CI/CD pipelines and static web hosting.
This page explains how to publish an Antora site to a <workspace>.bitbucket.io address.
Publishing methods
Bitbucket serves generated content from a repository of the same name. This allows users the flexibility in choosing where Antora runs:
-
Publish a pre-built site
Run Antora on another machine and commit the output to the site repository. -
Publish with Pipelines
Run Antora from a pipeline in the source repository, which commits the output to the site repository.
Playbook settings
Both methods require the playbook to set these keys:
site:
url: https://<workspace>.bitbucket.io (1)
urls:
latest_version_segment: latest
latest_version_segment_strategy: replace (2)
redirect_facility: static (3)
| 1 | The site URL MUST be the bitbucket.io address. |
| 2 | A latest version URL requires the replace strategy.
With the static facility, Antora ignores redirect:from and treats redirect:to as replace, as the latest version segment strategy documentation describes. |
| 3 | The static facility writes an HTML redirect page for each page alias and for the site start page.
Bitbucket reads no _redirects file or other server configuration.
The other facilities produce no working redirects on Bitbucket. |
Publish a pre-built site
This method allows a user to run Antora on any machine, such as a workstation or an external CI system, and commit the generated site to the site repository. The benefit of this method is that it requires no pipeline, no build minutes, and no access token.
Requirements
Publishing a pre-built site requires:
-
A Bitbucket Cloud workspace with an ID of lowercase letters, digits, and hyphens. The workspace ID becomes the hostname of the site.
-
A site repository named
<workspace>.bitbucket.iowithmainas its default branch.
Push access requires either SSH or HTTPS access.
-
Add an SSH key by visiting .
-
Add an HTTPS token by creating a repository access token on the site repository:
-
Open the site repository and select .
-
Create a token with the Repositories: Write permission.
-
Copy the token value, which Bitbucket displays only once.
-
Edit links
Antora derives the Edit this Page URL from the origin remote of the worktree and recognizes only bitbucket.org hosts.
When the origin remote is ssh.bitbucket.org, set edit_url on the content source:
content:
sources:
- url: .
branches: HEAD
edit_url: https://bitbucket.org/<workspace>/<source-repository>/src/{refname}/{path}
Build and commit the site
Build the site and publish it from a clone of the site repository:
-
Run Antora with the
CIenvironment variable set:$ CI=true npx antora antora-playbook.yml
Without the CIvariable, Antora resolves Edit this Page links to afile://URL for any page sourced from the worktree, which exposes the local path of the build machine. See default edit URL for details. -
Clone the site repository with its SSH or HTTPS URL, which Bitbucket shows under Clone on the repository page:
$ git clone <site-repository-url> site-repo
-
Replace the contents of the clone with the generated site. The
findcommand removes every entry except the .git directory. Files that the new build no longer produces disappear from the site.$ find site-repo -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + $ cp -R build/site/. site-repo/ -
Commit and push the site:
$ cd site-repo $ git add -A $ git commit -m "Deployed site" $ git push origin main
Publish with Pipelines
This method allows Antora to run from Atlassian’s infrastructure using a pipeline in the source repository, which commits the generated site to the site repository.
Requirements
Publishing with Bitbucket Pipelines requires:
-
A Bitbucket Cloud workspace with an ID of lowercase letters, digits, and hyphens. The workspace ID becomes the hostname of the site.
-
An Atlassian account with two-step verification enabled. Bitbucket enables Pipelines only for these accounts.
-
Pipelines build minutes. The Bitbucket plan of the workspace sets the monthly build minute allowance. Each run consumes build minutes from that allowance.
Create the site repository
In the workspace, create a repository named <workspace>.bitbucket.io with main as the default branch and no README or .gitignore file.
Create the source repository
Create a second repository in the same workspace for the Antora playbook, the content sources, and the bitbucket-pipelines.yml file.
Create a repository access token
The pipeline authenticates to the site repository with a repository access token. A repository access token grants access only to the repository that issued it. The token MUST be created on the site repository, not on the source repository.
-
Open the site repository and select .
-
Create a token with the Repositories: Write permission.
-
Copy the token value, which Bitbucket displays only once.
Enable Pipelines and store the token
Bitbucket accepts repository variables only after Pipelines is enabled on the repository.
-
Open the source repository and select .
-
Turn on Enable Pipelines.
-
Select and add a variable named
SITE_REPO_TOKENwith the token as its value and Secured checked.
Add the pipeline configuration
The bitbucket-pipelines.yml file at the root of the source repository runs on every push to main.
Its step performs these actions:
-
Installs the locked dependencies.
-
Runs Antora.
-
Clones the site repository with the token as the
x-token-authuser. -
Replaces the contents of the clone with the generated site.
-
Commits and pushes the result.
image: node:22
clone:
depth: full
pipelines:
branches:
main:
- step:
name: Build and deploy to bitbucket.io
caches:
- node
script:
- npm ci
- npx antora antora-playbook.yml
- export AUTHOR_NAME="$(git log -1 --format=%an)"
- export AUTHOR_EMAIL="$(git log -1 --format=%ae)"
- SITE_REPO="${BITBUCKET_WORKSPACE}/${BITBUCKET_WORKSPACE}.bitbucket.io"
- git clone --depth 1 "https://x-token-auth:${SITE_REPO_TOKEN}@bitbucket.org/${SITE_REPO}.git" site-repo
- find site-repo -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
- cp -R build/site/. site-repo/
- cd site-repo
- git add -A
- git diff --cached --quiet && echo "No site changes" && exit 0
- 'git -c user.name="$AUTHOR_NAME" -c user.email="$AUTHOR_EMAIL" commit -m "Deployed: ${BITBUCKET_COMMIT}"'
- git push origin HEAD:main
A script entry that contains a colon followed by a space MUST be quoted as a whole, as the git commit entry is.
Hosting behavior
Bitbucket Cloud static hosting serves committed files and reads no server configuration from the site owner.
Visibility
Bitbucket serves the site to anyone with its URL, without authentication, even when the site repository is private, as the Bitbucket Cloud website documentation states.
Server behavior
Bitbucket answers requests for the generated files as this table describes.
| Request | Response |
|---|---|
A path with uppercase letters |
The file as committed. Paths are case-sensitive. A request that differs only in case returns 404. |
A directory under |
The file with the correct content type. |
A directory without a trailing slash |
A 301 redirect to the same path with a trailing slash, then the directory’s |
A missing path |
A plain-text 404 response. Bitbucket does not serve the 404.html page that Antora generates. |
Any file |
A |