Connect GitHub and GitLab
Fistron reads your platform with a read token and writes to it only with a separate write token, only as pull or merge requests, and only for the actions and repositories you allow.
Before you start
- Which configuration you edit:
- for a control plane: the agent’s
fistron.tomlon its host (Install and register an agent); - for the local UI:
fistron.tomlin its workspace, or the Setup wizard (Run the local UI); - for a CI job: a CI file variable
FISTRON_CONFIG, owned by the platform team, not the repository.
- for a control plane: the agent’s
- Tokens you can create on your platform.
Give Fistron read access
-
Create a read token:
Platform Token GitHub fine-grained, read only: Actions: read, Contents: read, Pull requests: read. For the repository’s settings (compliance), also Administration: read. GitLab a project access token with the scope read_api. For protected branches and security settings (compliance), the Maintainer role. -
Put the token in an environment variable, for example
FISTRON_GITHUB_TOKEN. -
Name the variable and the allowed repositories in the configuration:
[acquisition.github] token_env = "FISTRON_GITHUB_TOKEN" # the variable's name, never the token repositories = ["acme/payments"] # nothing else is read # base_url = "https://github.example.com/api/v3" (GitHub Enterprise Server) [acquisition.gitlab] base_url = "https://gitlab.example.com" token_env = "FISTRON_GITLAB_TOKEN" projects = ["qe/shop"] -
Check it:
fistron integrations check --config fistron.tomlIt reads each repository, its code, its pull or merge requests, its checks and its CI runs, reports what is not readable, and on GitLab warns about write scopes on the read token.
fistron integrations access --config fistron.tomlchecks only what the tokens may read.A read the platform refuses says which token read (by its variable, or the organisation’s platform access from the control plane), the platform’s reason (a missing permission and which one, single sign-on not authorised, the organisation’s approval, a rate limit) and the fix. Review this request, an investigation and the CI checks say the same, never a bare
HTTP 403.
For Jenkins, see jenkins.md.
Let Fistron open pull or merge requests
-
Create a separate write token, for the repositories of one group only:
Platform The write token needs GitHub Contents and Pull requests read and write (classic: repo). For Fistron’s CI files, also Workflows read and write (classic:workflow). For verifying repairs, also Actions: read. For levelmerge, auto-merge allowed in the repository.GitLab the apiscope and at least the Developer role; for levelmerge, the role allowed to merge into the target branch. -
Allow the actions, each with its level:
[actions.github] token_env = "FISTRON_GITHUB_WRITE_TOKEN" repositories = ["acme/payments"] [actions.github.allow] # an action not named is refused propose-setup = "propose" # propose-test-repair = "propose" # propose or decide only # propose-test = "propose" # propose or decide only # review = "propose" # publish a pull request's review -
Run
fistron integrations check --config fistron.tomlagain. It checks that the write token is set and may write, and lists every action’s level. Levelmergeshows as a warning.
| Level | Fistron | A person |
|---|---|---|
propose |
opens or extends the pull or merge request | merges or closes it on the platform |
decide |
as propose |
merges or closes it on the platform; applies a platform’s setting of a compliance gap |
merge |
also merges its own proposal through auto-merge | reviews afterwards |
What Fistron proposes of a setting (the flaky quarantine, the Suite Health’s tests to review, the quality goals, a change policy, review rules, the test tiers) is never a pull or merge request and needs no level: it waits in Fistron for a manager to confirm (admin-repository-settings.md).
Repositories with different levels go into separate groups
([[actions.github]]). Branch protection always applies. Fistron writes
only below .fistron/ and its own CI files, never to a default branch
directly. In the local UI you change levels on Settings
(Run the local UI).
Fistron’s signature
What Fistron writes says so. A pull or merge request’s description ends
with Prepared in cooperation with Fistron · reviewed and merged by your
team, Fistron’s comments with Prepared in cooperation with Fistron, and
its commits with the trailer Prepared-with: Fistron <version>. Comments on
single lines of a review are not signed; the review’s summary is. To leave
the signature out, set signature = false in the group:
[actions.github]
token_env = "FISTRON_GITHUB_WRITE_TOKEN"
repositories = ["acme/payments"]
signature = false
Use a GitHub App instead of tokens
Instead of the two personal tokens, Fistron can act as your organisation’s
own GitHub App: its commits and comments show as <name>[bot], its tokens
last an hour, and its key stays where the agent runs.
-
Create the App in your organisation and install it on the repositories (github-app.md lists the permissions).
-
Generate its private key and put it where the agent runs.
-
Replace
token_envwith the App in both sections:[acquisition.github.app] id = 123456 private_key_file = "/run/secrets/fistron-app.pem" [actions.github.app] id = 123456 private_key_file = "/run/secrets/fistron-app.pem"If Fistron should also propose its CI files (
propose setup) or the CI change of your test tiers (propose-ci-change), give the App Workflows: read and write and addworkflows = trueunder[actions.github.app]. Without an App, the tiers’ CI change needs a token of its own, named asci_token_env: Fistron never changes CI files with the write token (Get your CI’s answer sooner). In the control plane’s Platform access, a GitLab access takes that CI token beside its read and write tokens; a GitHub access ticks “The App may change CI workflows”. Settings in Fistron’s UI shows per group how the CI change is written, or that it needs its token. The narrowest grant for it is in The CI change’s grant. -
Run
fistron integrations check --config fistron.toml.
The CI change’s grant
Fistron opens the change of your CI files (propose-ci-change, at most
decide) only with a grant of its own; a person merges it:
| Platform | Grant | Restrict it with |
|---|---|---|
| GitHub, an App (preferred) | the App’s Workflows: read and write, beside Contents and Pull requests, and workflows = true under [actions.github.app]; installed on the chosen repositories only |
branch protection or a ruleset on the default branch (a pull request and a review required); CODEOWNERS naming your platform team for .github/workflows/, with code-owner review required |
| GitHub, a token | a fine-grained token on the chosen repositories: Contents, Pull requests and Workflows read and write, named as ci_token_env; never a classic token |
the same, and the token’s expiry |
| GitLab | a project or group access token with api and write_repository, named as ci_token_env; the Developer role opens the merge request, Maintainer only where your project’s rules protect its CI files |
a protected default branch (merged by Maintainers); CODEOWNERS for .gitlab-ci.yml and .gitlab/ with code-owner approval; push rules |
| Jenkins | nothing in Jenkins: the Jenkinsfile changes in the repository through the grant above; the linter (lint_pipelines) reads with a Jenkins user of Overall/Read |
Jenkins’ credentials, jobs and agents are never touched |
Naming the token (or workflows = true) and allowing propose-ci-change
in the actions group is your consent. fistron integrations check fails a
GitLab CI token below Developer (it cannot push a branch) and says when it
is below Maintainer.
Add Fistron’s CI files
Fistron proposes its CI files as one pull or merge request on the branch
fistron/setup. Use one of:
- the last step of the local UI’s Setup wizard, Propose the setup;
- the operation
propose-setup(local Operations, or Work in a control plane); fistron propose setup --config fistron.toml --repository acme/payments --workflow ci.
What you get:
| Platform | Files |
|---|---|
| GitHub | .github/workflows/fistron.yml (fistron-action: the analysis of failed runs of the named workflows and each fix, verified by your CI) and .github/workflows/fistron-pr.yml (fistron-action again: the assessment of a pull request’s change, and its review) |
| GitLab | .gitlab/fistron.gitlab-ci.yml: on GitLab.com Fistron’s components fistron and fistron-change, on a self-managed GitLab the hidden jobs .fistron_rca and .fistron_change. Fistron never edits your .gitlab-ci.yml: the description says which include and jobs to add, and the CI variable FISTRON_GITLAB_TOKEN |
Review the workflow names in the description, then merge it.
Upload CI reports to a project
With a control plane, the CI templates also upload their reports to a project when these are set:
| Name | Kind | Value |
|---|---|---|
FISTRON_CP_URL |
variable | your control plane, for example https://app.fistron.io |
FISTRON_CP_PROJECT |
variable | the project’s id or slug |
FISTRON_CP_TOKEN |
secret (masked) | an automation token of an engineer of the project, allowed to write documents |
A failed upload never fails the job. To upload by hand:
fistron upload --control-plane https://app.fistron.io --project payments \
--prefix "manual/" fistron-report/reports
with the token in FISTRON_CP_TOKEN.
Check the decision files in pull requests
Fistron keeps these settings itself (Set your repositories’ settings).
While a repository still has its own .fistron/quarantine.toml,
.fistron/suite-health.toml or .fistron/selection.toml and they are not
yet set in Fistron, add a step that checks them when they change, so a
broken file is caught before Fistron reads it
(ci-job.md).
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| GitHub refuses the setup proposal | The write token lacks Workflows read and write (classic: workflow). |
| A level cannot be raised in Settings | The write token of that group does not pass its check: the preview says why. |
fistron ci sends no request |
CI_SERVER_URL (GitLab) or GITHUB_API_URL (GitHub) must equal the configured base_url, and the repository must be on the allowlist. |
| GitLab job logs cannot be read in CI | The CI job token cannot read job logs: use a project access token with read_api. |
manifest unknown when the CI pulls the image |
The image tag does not exist; use a released version. |
| A pull request from a fork is not assessed | Fork runs are not read with the workflow’s token. |
| The setup proposal fails because one was opened meanwhile | Run it again: it extends the open proposal. |
Details: github.md, gitlab.md, actions.md, setup.md, ci-job.md.