Source Control
Zenfra reads your infrastructure code from a Git provider through a source control integration, managed under Integrations in the sidebar. Adding, changing and removing integrations requires the Admin role (Only organization administrators can add integrations.).
Supported providers
| Provider | Where it runs | How to connect |
|---|---|---|
| GitHub | GitHub.com | GitHub > Add Account installs the Zenfra GitHub App; choose the repositories or organizations it may access. |
| GitHub Enterprise Server | Inside your network | GitHub > Add via connector, through a VCS Connector. |
| GitLab | GitLab.com, or any GitLab reachable from the internet | GitLab > Add Account with Hosting GitLab.com or reachable from the internet, the instance Base URL and a Personal access token with the read_api and read_repository scopes. |
| GitLab | Self-managed, inside your network | Hosting Self-managed, inside your network, through a VCS Connector. |
| Bitbucket Data Center | Inside your network | Through a VCS Connector only. Bitbucket Cloud is not supported. |
| Azure DevOps Server | Inside your network | Through a VCS Connector only. Azure DevOps Services is not supported. |
A stack can also point at a Raw Git URL instead of an integration: a public HTTPS repository. Raw Git sources have no push or pull-request triggers.
Managing an integration
Each provider page lists its connected accounts with a status badge (Connected, Error, Pending or Disabled) and a menu with Verify connection, Enable / Disable and Remove. Open an integration for its detail page:
- Verify connection checks the credentials and records when they last worked.
- Sync Repositories discovers the repositories the integration can see (
Synced {n} repositories ({new} new, {updated} updated)). Each repository has an Enabled switch; only enabled repositories can be selected as a stack's source. - Connection shows
DirectorVia connector {name}with the connector's health. While the connector is offline, repository sync and browsing fail until it reconnects; while it is degraded, browsing works but archive downloads, and therefore runs, do not.
An integration that a stack uses as its source cannot be removed. The refusal (409, error code integration_in_use) names the stacks; change their source or delete them first. A connector-backed integration also cannot be re-pointed at another connector; removing it and creating a new integration is the only way to reconnect.
Scoping an integration to a space
An integration is organization-wide by default: every stack in the organization can use it. An Admin can scope it to a space; then only stacks in that space and in the spaces below it can use it. Integrations that existed before scopes were introduced stay organization-wide until an Admin scopes them.
To scope an integration, open its detail page and choose a space under Space scope, or Organization-wide to remove the scope. Through the API, PATCH /api/v1/vcs/integrations/{id} with {"space_id": "<space id>"} scopes it and {"space_id": null} makes it organization-wide again; POST /api/v1/vcs/integrations accepts space_id too. A GitHub App installation always starts organization-wide; scope it on its detail page after installing. Each change is recorded in the audit log with the old and new scope and the stacks the new scope leaves without a usable source.
| What happens | When the integration is out of the stack's scope |
|---|---|
| Choosing a stack's source | The integration and repository pickers list only what the stack's space may use. Creating a stack, editing it or changing its source with an integration from outside the scope is refused (422, error code integration_not_in_space). |
| Re-scoping an integration that stacks already use | Allowed. Each of those stacks shows a banner on its page, and new runs are refused (422 integration_not_in_space): manual and API runs, push runs and pull-request runs. A planned pull-request run of such a stack is cancelled at the pull request's next update. |
| A run created before the re-scope | A run that is still queued, or waiting for approval, fails when a worker picks it up, with error code INTEGRATION_NOT_IN_SPACE. Its source is never fetched with the integration's credential. |
| Drift schedules | A scheduled drift check of such a stack creates no run, so no failed drift check is recorded and no drift email is sent. The stack's banner and the audit log entry are the signals. A drift run created before the re-scope fails at pick-up and is recorded as a failed check. |
To fix a stack, either select a source it may use, or ask an Admin to widen the integration's scope (to a space above the stack, or organization-wide). Widening takes effect at once: no rebind is needed.
A Member with a Write grant can bind a stack only to integrations usable from the stack's space; managing integrations, scopes included, stays with Admins.
Deleting a space is not a way to revoke an integration: an integration scoped to a deleted space can be used by no stack, so change its scope or remove it instead.
In provider versions that support space_id, the Terraform resource zenfra_vcs_integration takes it: changing it updates the integration in place, and removing it makes the integration organization-wide.
How source is used in runs
- A run is pinned to a commit. When a run is created, the branch is resolved to a commit, and both plan and apply use that commit even if the branch moves in between. See Source commit.
- The whole repository is delivered to the worker, and the tool runs in the stack's project root (the Path field, repository root when empty). Files above the project root, such as a local module at
../modules/vpc, are reachable. - The project root must contain a configuration file directly: a
.tfor.tf.jsonfile (OpenTofu 1.8 and later also accept.tofuand.tofu.json). A root whose only Terraform files sit in subdirectories is refused. A wrong root fails the run in the Preparing phase withproject root "<path>" does not exist in the repositoryorcontains no terraform configuration file.
Triggers
Runs start from four sources. The Runs tab of a stack can filter on the first three (Manual, Push, Pull Request); drift runs carry a Drift badge.
- Manual: the stack's Trigger menu.
- Push: enable Push Trigger under Automation Triggers in the stack's source settings. A push runs the stack when a changed file is under its project root or matches one of its Project globs. Globs add paths outside the project root, for example
modules/**for shared modules; with no project root, every push to the branch already triggers the stack and globs add nothing. When the provider cannot say which files changed (very large pushes, pushes with no commits), the stack triggers rather than skips. For self-managed GitLab behind a connector, push events reach Zenfra through the connector's webhook listener (see Optional extras); the connector path relays GitLab push events only today. - Pull Request: on GitHub.com, through the GitHub App, a pull request whose base is the tracked branch creates a proposed (plan-only) run. Pull-request runs are not scoped by project root or globs. Other providers do not deliver pull-request events today.
- Drift: a drift schedule on the stack.