Continuous integration¶
Several things connect Midair to a build system: a command-line client that runs inside a job, a Jenkins plugin around that client, a GitHub Action, and an incoming webhook that starts a template from outside.
Two of these do a job that the others do not: they ask Midair for a verdict and
block on it. The Jenkins midairGate step and the GitHub Action’s check mode
each run a template against a commit, wait for it to settle, and fail the build
or the merge unless it passed. They reach that verdict over the plain HTTP API,
not through the client. A hard gate has one deterministic answer, and the
client’s richer surface adds nothing to it.
Jenkins¶
The Jenkins plugin holds the servers, resolves the credential for the job that
asks, and puts both into the environment of a block. The work itself is done by
midair-cli inside the job, on the machine that already has the checkout.
See Command-line client.
withMidair('corp') {
sh 'midair analyze --run https://midair.example.com/analysis/edit?id=12 -- make -j8'
sh 'midair push'
}
Inside the block:
Variable |
Source |
|---|---|
|
The URL of the installation. |
|
A username and password credential. |
|
A secret text credential. |
The client exchanges the username and the password for a session at the start of each run, and it keeps the session nowhere. A build agent is shared, and a credential left in its keyring outlives the job that needed it.
Jenkins masks the secrets in the console and marks them sensitive in the environment view of the build.
A secret text credential that holds a Midair API token becomes
MIDAIR_TOKEN, and that is what a build agent should hold. A token expires
on its own schedule, is revoked on its own, and may do only what its scopes
name. A password can do everything that the account can do, for as long as it
lasts. See API tokens and the HTTP API.
The plugin checks the shape of the credential when the block opens. A token
reads as mid_<id>_<secret>, so a secret text credential that holds
something else is refused there, with the reason.
Configure the servers under Manage Jenkins → System → Midair: one entry per
server, with a name, a URL and a credential. The name is what
withMidair('name') asks for.
Test connection asks the server for its state. That address takes no credential. The answer says whether the host is a Midair server, whether the controller reaches it, and whether it is busy.
The same configuration in Configuration as Code:
unclassified:
midair:
installations:
- name: "corp"
serverUrl: "https://midair.example.com"
credentialsId: "midair-corp"
The plugin is early. withMidair works with either kind of credential, and
the configuration form checks the server. For the withMidair path the client
still has to be on the PATH of the agent, and its exit code is the verdict.
Release gate¶
The one thing the plugin does without the client is the release gate. The
midairGate step runs a run template against a commit, waits for it, and
fails the build unless it passed — the thing a pull-request check or a release
stage needs. It talks to the HTTP API itself, because the answer is a single
pass or fail. It needs no client on the agent.
// Fail the build if the test run is not green.
midairGate(installation: 'corp', templateId: 128, repoRef: env.GIT_COMMIT)
// Or read the verdict and decide for yourself.
def verdict = midairGate(installation: 'corp', templateId: 128,
repoRef: env.GIT_COMMIT, failOnFailure: false)
echo "midair says: ${verdict}" // 'success' | 'failure' | 'neutral'
kind chooses what the gate runs. test (the default) runs a test template
and reads the pass and fail counts; the verdict mirrors the workspace badge.
analysis runs an analysis template and reads its quality gate. An analysis
run takes no per-commit ref, so repoRef and the other ref pins apply to
test only.
midairGate(installation: 'corp', templateId: 1, repoRef: env.GIT_COMMIT) // tests
midairGate(installation: 'corp', templateId: 9, kind: 'analysis') // code quality
The installation’s credential must be a secret text token here — the gate
authenticates with a bearer token and nothing else. The token needs the
runs and read scopes. See API tokens and the HTTP API.
The verdict rule, and the meaning of test and analysis, are the same as
for the GitHub Action below.
GitHub Actions¶
interpretica-io/midair-action wires a GitHub repository to a Midair
instance. A client copies a workflow from the action’s examples/ into
.github/workflows/ and sets the secrets and variables for their own
instance; nothing points at a shared one. The action does two separate jobs,
chosen by mode.
The bot¶
In the default mode the action is a bot. A trusted author is the repository
owner, a member or a collaborator. When one of them mentions @midairbot in a
pull request, an issue or a review comment, the bot gathers the triggering text
and, for a pull request, the changed-file diff, and replies with an answer from
Claude. Comments from other bots are ignored, so two bots cannot talk in a loop.
When the action is given the instance’s MCP URL and a token, it connects the agent to the MCP endpoint endpoint. The agent then calls Midair tools for authoritative project, test and analysis data while it answers. Without them it still replies, but from the GitHub context alone. Answering a mention needs an Anthropic API key; the run fails with a clear message when the key is absent.
An external program can also ask the bot to post a fixed comment, through a
repository_dispatch or a workflow_dispatch event that names the issue or
pull request and the exact body. This path runs no agent and needs no Anthropic
key.
Note
GitHub runs a comment-triggered workflow from the file on the repository’s default branch, never the branch under review. The bot workflow, and any change to it, must be committed to the default branch to take effect.
The release gate¶
With mode: check the action publishes a GitHub check-run instead of
reacting to comments. It is the counterpart of the Jenkins midairGate step
and reaches the verdict the same way. There are two ways to get the verdict.
The first computes it in Midair. Given a template id, the action runs that
template over the HTTP API, polls until the run settles, and derives the
verdict itself — MCP has no part in it. midair-kind chooses what runs:
test(the default) runs a test template pinned to the commit under review and reads the pass and fail counts. The verdict mirrors the workspace badge: green when the run finished with no failures and at least one pass; red on any failure, a run that broke before it produced a result, or a run that never settled; neutral when only skipped, or nothing ran.analysisruns an analysis template and reads its quality gate: a passing gate is green, a failing gate is red, an unset gate is neutral. An analysis run takes no per-commit ref — it runs against the template’s configured branch — so the ref inputs are ignored, and the gate reflects the latest analysis of that branch. Run both kinds with two steps.
The second way takes a verdict that some other run already decided — a Jenkins build, a Test Environment run — and only attaches it to the commit as a check.
# Compute the verdict in Midair and block the merge on it.
permissions:
checks: write
steps:
- uses: interpretica-io/midair-action@v0
with:
mode: check
midair-api-url: ${{ vars.MIDAIR_API_URL }} # the HTTP API base
midair-key: ${{ secrets.MIDAIR_KEY }} # token with runs + read
midair-template-id: '128' # numeric run-template id
# midair-kind: test # or 'analysis'
check-name: midair/release-gate
check-sha: ${{ github.event.pull_request.head.sha }}
Mark the check name required in branch protection and the pull request cannot merge until it is green. In a release workflow the step fails the job on a failing verdict, which blocks the release. A run that never settles is treated as a failure on purpose: a gate that hangs must not let a release through.
A run template is named by its numeric id for now; a lookup by name is planned.
Endpoints, token and scopes¶
The bot and the gate reach Midair through two different surfaces, kept in two inputs that share one token:
Input |
Value |
Used by |
|---|---|---|
|
the MCP endpoint endpoint, e.g. |
the bot, for Midair tools |
|
the HTTP API base, e.g. |
the gate, to compute the verdict |
|
one |
both |
On an instance served behind a proxy, both sit under /api
(https://midair.example.com/api and .../api/mcp).
One token serves both surfaces if it carries every scope the modes in use need:
mcp for the bot’s tools, and runs with read for the gate. A token
that is short a scope does not fail with an error. The bot still replies, only
without Midair data, because the tool calls are refused at the server. See
API tokens and the HTTP API.
As on the MCP endpoint endpoint, the token’s account decides what the bot can see: it sees every workspace that account may see, not only the project wired to the repository the comment is in. The action tells the agent which repository it is in, but it does not confine the answer to a matching project. On an instance that hosts one project, or one tenant, a single shared token is fine. On an instance that hosts projects of different clients, give each repository a token of an account that sees only its own workspace; the token, not the action, is the boundary.
Incoming webhooks¶
A webhook is an address that Midair publishes, and a token that opens it. A call to it starts one thing: a test template, or an analysis. That is the whole configuration surface. The case that this serves is “CI finished a build, run the nightly suite”.
Configure the list under Settings, then Integrations, then Webhooks. Each entry names what it starts:
[
{"name": "CI nightly", "enabled": true, "action": "run_test",
"target": 12, "token": "…"}
]
The token is the credential. Midair compares it in constant time. An entry with no token is refused, and not treated as open.
A webhook starts a run in the same way as the button on the screen: the same fork, the same validation, the same failure handling.
Midair writes the hook definitions into a Horizon installation on the same server, and asks Horizon to reload them. Horizon verifies the caller, runs the command, and keeps the logs and the run history. Midair finds the Horizon installation by reading its settings file, so nothing about Horizon is configured twice.
The only setting that Midair needs for this is its own Public URL. Horizon calls back to it, and the hook addresses are built from it.
Jira¶
Midair can run the tests of a workspace when a Jira ticket moves into a given
state. Jira calls POST /jira/webhook with the ticket, and a list of rules
in Midair decides which workspace and which test templates run.
The credential is a personal API token with the runs scope. See
API tokens and the HTTP API. Each run starts as the owner of the token, through the same
handler as the Run button. The seats and the project access of that account
decide what the webhook can start. A rule that points at a workspace where the
account cannot run tests starts nothing, and the answer says so. To close the
webhook, revoke the token.
In Jira, use an Automation rule:
Trigger: Issue transitioned.
Action: Send web request to
https://<midair>/jira/webhook, methodPOST, body Issue data (Jira format), headerAuthorization: Bearer mid_….
The system webhooks of Jira cannot send that header, so use Automation.
Configure the rules under Settings, then Integrations, then Jira. The screen also shows the address to give Jira. An administrator edits the rules of the instance. On a shared instance, each customer edits only their own rules, and only a token of their own account fires them.
The rules are a list. Midair tries them in order, and the first rule that matches decides. A last rule with no conditions is therefore the default workspace.
[
{"name": "Network QA", "enabled": true,
"statuses": ["Ready for QA"],
"conditions": [{"field": "project.key", "op": "eq", "value": "NET"},
{"field": "labels", "op": "contains", "value": "tcp"}],
"workspace": 5, "templates": [],
"ref_field": "customfield_10020", "ref_target": "repo_git_ref",
"jira_url": "https://corp.atlassian.net", "credential": 4,
"comment": true, "on_pass": "Done", "on_fail": "Reopened"},
{"name": "Default", "statuses": ["Ready for QA"], "workspace": 1}
]
statusesThe states that fire the rule. When the body has a changelog, the rule fires only if the changelog moves the ticket into one of these states. An edit of a ticket that is already in the state starts nothing. A rule with no states never fires.
conditionsAll of them must hold.
fieldis a field of the ticket (labels,priority,customfield_10010), a path into one (project.key,components.name), orkeyfor the ticket key. A wrapped value counts by the name a person sees: thenameof a status, thevalueof a select, thekeyandnameof a project. The operators areeq(the default),ne,inandnot_in(withvalues),contains,existsandabsent. Comparisons ignore case.workspaceandtemplatesThe workspace whose tests run, and which of its test templates. With no templates, every test template of the workspace runs. A template that is not in the workspace is reported and not run.
ref_fieldandref_targetA ticket field that holds a branch, a tag or a commit, and the checkout it applies to:
repo_git_ref(the default),ts_git_reforte_git_ref.owner0for a rule of the instance. Any other value is an account, and only a token of that account fires the rule.jira_url,credential,comment,on_passandon_failWhere to report the result, and how. See Reporting back below.
Each run is named after its template and the ticket key. Its notes link the ticket.
Jira repeats a delivery when it thinks that a delivery failed. One event starts one run per template: a second delivery of the same event starts nothing, and the answer names the run that the first delivery started.
Reporting back¶
When a run that a ticket started is finished, Midair can write to the ticket:
a comment that says whether the run passed, how many tests passed and failed, and links the run (the link needs the Public URL);
the transition that the rule names for the verdict:
on_passwhen no test failed,on_failwhen a test failed or the run itself failed. Give the name of the transition or the name of the state that it leads to. A stopped run gets a comment and no transition.
Midair signs in to Jira with a stored credential (see API tokens and the HTTP API for where credentials are kept). For Jira Cloud, put the e-mail address of the Jira account in the login of the credential, and an API token in its secret. For Jira Data Center, leave the login empty and put a personal access token in the secret. A rule can use only a credential of its owner.
The run records what reporting did: commented, moved to Reopened, or the
reason why nothing was reported.
On a shared instance, the Jira address must be https, and Midair does not
connect to an address inside its own network (loopback, private ranges,
link-local). A customer chooses the address, and Midair makes the request, so
the address must not lead into the server’s network.
Jira app¶
Instead of an Automation rule and a stored Jira credential, a Jira administrator can install Midair for Jira, for Jira Cloud or for Jira Data Center. The app notices the change of state itself, writes the result into the ticket under its own identity, and shows the runs of the ticket in a panel. A rule then needs no Jira address and no credential. See Midair for Jira.
Instance state¶
GET /system/state says what the instance is doing. It takes no credential.
An orchestrator holds no account here. A probe that must be provisioned first
is a probe that is absent when somebody wants it.
The answer carries counts and nothing else. It names no run, no workspace and no device.
{
"succeeded": true,
"checked_at": 1789045678,
"busy": true,
"busy_domains": ["testing"],
"driven_here": 1,
"testing": { "busy": true, "unsettled": 2, "driven_here": 1 },
"analysis": { "busy": false, "unsettled": 0, "driven_here": 0 },
"runtime": { "busy": false, "moving": 0, "up": 2 }
}
The answer reports two readings of “busy”, because they answer two questions.
busyThe cautious reading. A record says that it has not finished, or this process is working on it.
driven_hereThe narrow reading. How much of that work this process drives, which is what a restart would interrupt.
The two differ after a restart. A run that was in progress when the server
stopped still says running, and nothing drives it.
A run is work while its state is queued, running or analyzing. A
template is never work. A device is work while it is building, starting
or stopping; a device that is merely active is not.
Each call scans the three collections. Poll it on the order of seconds, and not of milliseconds.
Badges¶
A workspace publishes three status badges for a README, a wiki page or a dashboard. See Badges.