Git hosts

Connect GitLab, Bitbucket Cloud, Azure DevOps, GitHub Enterprise Server and Gitea or Forgejo, cloud or self-hosted, so pushes, previews, commit statuses and merge request comments work as they do on GitHub.

GitHub is connected as a GitHub App. Every other git host is connected with an access token and a webhook:

HostWhere it runsSigns in withStatus Wardn postsComment Wardn posts
GitLabgitlab.com or self-managedAccess tokenCommit statusMerge request note
BitbucketCloud (https://bitbucket.org/<workspace>)Access token, or an app password with its user nameBuild statusPull request comment
Azure DevOpsServices (https://dev.azure.com/<organization>) or Server (a collection)Personal access tokenCommit statusPull request thread
GitHub Enterprise ServerYour own instanceAccess tokenCommit statusPull request comment
Gitea / ForgejoYour own instanceAccess tokenCommit statusPull request comment

The same four things work everywhere, only the names differ: pushes become snapshots, a pull or merge request becomes a preview, every sync and release reports its state on the commit, and the preview comment is kept up to date in place. Bitbucket Data Center is not supported.

Wardn's own tests run against fakes of each host's API, built from the vendors' public documentation. No real GitLab, Bitbucket, Azure DevOps, GitHub Enterprise Server or Gitea was available. The first time you connect one, use the Test connection button and a test webhook event, and tell us what differs.

Connect a host

You need integration:manage (Owners and Admins) and a server with WARDN_SECRET_MASTER_KEY set, because Wardn keeps the token in its secret store. On the Integrations page, Connect the host's tile, or:

curl -fsS -X POST "$WARDN_API_URL/api/v1/git-hosts" \
  -H "Authorization: Bearer $WARDN_TOKEN" -H 'Content-Type: application/json' \
  -d '{"kind":"gitlab","name":"platform group","baseUrl":"https://gitlab.example.com","token":"…"}'

kind is gitlab, bitbucket, azure-devops, github-enterprise or gitea. The base URL is the instance's address; Wardn adds the API path itself. GitLab's defaults to https://gitlab.com; Bitbucket's names the workspace; Azure DevOps' names the organization or a Server collection; GitHub Enterprise Server's and Gitea's have no default.

Wardn checks the token with the host before it keeps anything. The answer carries the connection's webhookPath and, once, its webhookSecret. A source then reads through the connection when its credentials reference is githost:<connection id>.

The token and the webhook secret are kept in the secret store and are never returned. The screen shows the token as a reference with a Found check, and the signing token masked to its last four characters; Rotate makes a new one and shows it once.

Private certificate authority

An instance whose certificate comes from a private authority takes its certificate as caPem (PEM certificates only; a private key is refused). It is trusted for that connection alone, both for API calls and for reading the repository.

Where the host's address may point

An address must be https:// (unless the install allows http for development), with no user name, query or fragment. It cannot name this machine or an internal host. After the name resolves, and at every connection, Wardn refuses loopback, link-local and cloud metadata addresses, and private ones when the install refuses them (WARDN_CONNECTIONS_BLOCK_PRIVATE_ADDRESSES). A redirect is never followed, so one cannot lead past that check. The token is only ever sent to the connection's own address.

The webhook

Set up the webhook on the host once, after adding:

HostWhat to do
GitLabUnder Webhooks, add the URL; paste the signing token as the secret token; tick push and merge request events.
BitbucketUnder Webhooks, add the URL; paste the signing token as the secret; tick repository push and pull request events.
Azure DevOpsUnder Service hooks, add a Web Hooks subscription for code pushed and pull request created and updated; paste the signing token as the password of basic authentication (any user name).
GitHub Enterprise ServerUnder Webhooks, add the URL with content type application/json; paste the signing token as the secret; tick push and pull request events.
Gitea / ForgejoUnder Webhooks, add a Gitea webhook; paste the signing token as the secret; tick push and pull request events.

How each host proves a delivery: GitLab sends the secret itself (X-Gitlab-Token), Bitbucket and GitHub Enterprise Server sign the body (HMAC-SHA256, X-Hub-Signature and X-Hub-Signature-256), Gitea and Forgejo sign it too (X-Gitea-Signature, or X-Hub-Signature-256), and Azure DevOps sends it as basic authentication. Only the signed ones prove the body was not changed in transit; for GitLab and Azure DevOps rely on TLS.

Every delivery is checked before its body is read, in constant time; a body over 5 MiB is refused; a delivery id is remembered for 72 hours and a repeat is refused; and a connection that is unknown, or whose secret does not match, gets the same answer. The organization is the one that owns the connection, never anything in the payload. Pushes the webhook misses are still found by the once-a-minute check.

What Wardn posts back

On the connection's page, Posted back lists what Wardn writes to the host, each with a switch:

  • Commit status on sync, wardn/sync: a snapshot is taken, while it applies, and when it settles.
  • Commit status on release, wardn/release: a release starts, moves wave and finishes or rolls back.
  • Pull or merge request comment with the preview, one comment edited in place on every push.
  • Preview link in that comment, struck through when the preview closes.

Environments limits which deployments post (none means all), and Projects limits which repositories the connection covers. A paused connection posts nothing and opens no previews.

A post that fails is retried three times over about a minute and then skipped: a failed status never holds a release or a preview. A token that lacks a permission is a result on the page (403 · token lacks api scope), not an error. Each post, and each delivery received, is listed on the connection's page, newest first. They are timeline entries, not audit entries; connecting, changing settings, rotating and disconnecting are audited.

The rendered diff in the merge request comment is not posted yet: the comment carries the preview's state and link. Choosing a connection's repositories is by path, not from a list the host returns.

When the host is down

Pushes are found by the once-a-minute check once it is back. Posts wait in the worker's queue and nothing is posted twice. Previews and comments pause; releases keep going. The tile shows the host's health like any other integration (Integration health).

Not done yet

  • Reaching a host through an agent in your network, for hosts that cannot be reached from the internet, is not available: Wardn connects directly.
  • Reading the token from an external Vault path: the token is kept in Wardn's own secret store.

On this page