Midair for Jira

Midair for Jira is an app that a Jira administrator installs on a Jira site. When a ticket moves into a given state, the app asks Midair to run the tests. When the run is finished, the app writes the result into the ticket.

There are two editions. They do the same work and speak the same protocol to Midair:

Jira Cloud

Jira Data Center

Form

A Forge app.

A plugin jar, for Jira 10.x.

Who writes the comment

The app itself. The comment shows Midair as its author.

The Jira user that the configuration names, for example a midair service account.

Configuration screen

Settings, then Apps, then Midair.

Administration, then Manage apps, then Midair configuration.

Who may configure it

Jira administrators.

Jira system administrators.

Midair decides what runs: the Jira rules under Settings, then Integrations, then Jira. See Jira. The app decides when to ask, and it writes the answer into the ticket.

Without the app, the same rules work with a Jira Automation rule and a Jira credential stored in Midair. See Jira. The app replaces both: no Automation rule, no Jira credential in Midair.

What the app needs

  • A Midair server that Jira can reach. The Cloud app runs in the Atlassian cloud, so the server must have a public https address. localhost and addresses inside a company network do not work. The Data Center plugin runs inside Jira, so the server must be reachable from the Jira host.

  • A way back. When a run is finished, Midair calls the app. On Cloud that address is in the Atlassian cloud, and nothing has to be opened. On Data Center, the Midair server must reach the Jira base URL.

  • A Midair API token with the runs scope. See API tokens and the HTTP API. Every run that the app starts, starts as the owner of the token. The seats and the project access of that account decide what may run. Use the account of a service, not the account of a person: when the person leaves, the token stops working.

  • Jira rules in Midair that name the states, the workspace and the test templates.

Install

Jira Cloud

A site administrator opens the installation link of the app, picks the site, and accepts the permissions. The app asks for:

  • read:jira-work: read the ticket and its transitions;

  • write:jira-work: add the comment and move the ticket;

  • storage:app: keep the configuration, the token and the list of the runs that it has reported.

The app may call any address. Each customer has a Midair server of their own, so the address is not known in advance. The app calls only the address that the administrator enters.

Jira Data Center

  1. Go to Administration, then Manage apps, then Upload app.

  2. Upload midair-jira-datacenter-<version>.jar.

  3. Open Configure next to the app.

Create the service account that will write the comments, for example midair. Give it, on the projects where the rules apply:

  • Browse Projects;

  • Add Comments;

  • Transition Issues, if a rule moves the ticket.

Configure

The configuration screen has the same fields in both editions:

Midair URL

The address of the server, for example https://midair.example.com. A trailing slash is removed.

Midair API token

mid_<id>_<secret>, with the runs scope. The field is write-only. After you save, the screen says only whether a token is set. Leave the field empty to keep the token. To change it, enter a new one.

Comment as (Data Center only)

The Jira user that adds the comments and performs the transitions.

Test connection

Asks Midair for the runs of a ticket that does not exist, with the token. The answer is shown in words:

  • Connection succeeded: the address is right, and the token is valid and has the runs scope.

  • Unauthorized (401): the token is wrong, revoked or expired.

  • Forbidden (403): the token has no runs scope, or the account is not active.

Report URL

The address that Midair calls when a run is finished. It is shown for information. The app sends it to Midair with each ticket, so you do not enter it anywhere.

The configuration stays in Jira. On Cloud, the token is kept in the encrypted storage of the app. On Data Center, it is kept in the plugin settings of Jira. The token is never sent to a browser. The issue panel and the configuration screen ask the server side of the app, and the server side calls Midair.

Write the rules

The rules are the same rules as without the app. See Jira. With the app, a rule needs no jira_url and no credential. Three fields still decide what the app writes:

comment

true to add a comment with the result.

on_pass

Where to move the ticket when no test failed.

on_fail

Where to move the ticket when a test failed, or the run itself failed.

A rule that fires for the app:

[
  {"name": "Network QA",
   "statuses": ["Ready for QA"],
   "conditions": [{"field": "project.key", "value": "NET"}],
   "workspace": 5,
   "comment": true, "on_pass": "Done", "on_fail": "Reopened"}
]

The rules that fire are the rules of the instance, and the rules that the owner of the token owns. On a shared instance, only the rules of the owner of the token.

When the app starts a run

The app starts runs in two cases.

A ticket changes state. Jira tells the app about every change of a ticket. The app ignores every change in which the state stays the same: an edit of the description, a label, a comment. When the state changes, the app reads the whole ticket and sends it to Midair, together with the change: “from In Progress to Ready for QA”.

Somebody clicks Run again in the issue panel. The app sends the ticket without a change. Midair then compares the current state of the ticket with the rules. Each click starts new runs.

Midair then takes the rules in order. The first rule that matches decides. A rule matches when:

  • the ticket moved into one of the statuses of the rule. For Run again: the ticket is in one of them now;

  • every one of its conditions holds;

  • it is a rule of the instance, or a rule of the owner of the token.

The rule starts the test templates of its workspace, or all of them when it names none. When no rule matches, nothing starts. That is not an error.

One change of state starts one run for each template. When Jira delivers the same change twice, the second delivery starts nothing.

The app never reacts to its own changes: its comments, and the transitions that it performs. A rule that moves a ticket into a state that fires another rule does not start a loop. On Data Center, this covers every change that the Comment as user makes, including changes by hand.

When the app is not configured, it starts nothing.

What the app writes

When a run is finished, Midair calls the report URL of the app. The call carries the number of the run and the ticket key, and nothing else: no result, no credential. The app then asks Midair for the result with its own token. A forged call can, at most, make the app look up a run that it may see anyway.

If the rule says comment, the app adds a comment:

Midair test run nightly · NET-42 ✅ passed (118 passed, 0 failed) — Open the run

Midair test run nightly · NET-42 ❌ failed: 2 tests failed (116 passed, 2 failed) — Open the run

Midair test run nightly · NET-42 ⚠️ was stopped — Open the run

Open the run is the link to the run. On Data Center, the icons are the Jira icons (/), (x) and (!). The counts are left out when both are zero. The link is left out when Midair has no Public URL. See Settings.

If the rule names on_pass or on_fail, the app moves the ticket. The name in the rule can be the name of the transition (Pass QA) or the name of the state that it leads to (Done). Case is ignored. When no open transition of the ticket matches, the ticket stays where it is. The comment is still written, and the app notes the reason in its log.

A stopped run gets a comment and no transition.

Each run is reported once. The app keeps the numbers of the runs that it has reported.

The issue panel

The panel Midair test runs on a ticket lists the runs that the ticket started, the newest first. For each run it shows the name, as a link to the run in Midair, the state, the verdict, and the counts.

Run again sends the ticket to Midair again and refreshes the list. The panel shows the answer: how many runs started, No rule matched this issue, or the error that Midair returned.

The panel lists the runs that the owner of the token may see. Everybody who can see the ticket in Jira sees the panel and can click Run again.

Remove the app

Uninstall the app in Jira. On Cloud, the configuration and the token are deleted with it. Then revoke the token in Midair. See API tokens and the HTTP API. The runs that the app started stay in Midair.

To stop the app without removing it, revoke the token. Every call from the app then fails, and nothing starts.

Troubleshooting

What you see

What to check

A state change starts nothing, and the panel lists no runs.

The rules: the state is in statuses, and the conditions hold. Click Run again: if the panel says No rule matched this issue, the rules are the cause. The rule must belong to the owner of the token, or to the instance.

The panel says Midair is not configured.

Enter the URL and the token on the configuration screen.

The panel says Could not reach Midair.

The URL. For Cloud, the address must be public and https.

Test connection says 401 or 403.

The token: revoked, expired, or without the runs scope. Issue a new one. See API tokens and the HTTP API.

A run is listed, but no comment comes.

comment in the rule. On Data Center: the Midair server can reach the report URL, and the Comment as user can add comments. The run in Midair records what reporting did.

Run again says Midair reported errors.

The account of the token cannot run tests in that workspace: seats, project access. The error names the reason.

The comment is there, and the ticket did not move.

The name in on_pass or on_fail. The ticket must have an open transition of that name, or one that leads to a state of that name, from where it is now. On Data Center, the Comment as user also needs the Transition Issues permission.

On a shared Midair instance, every ticket is refused with midair.report_url.

The report URL must be https and lead to a public address. The Cloud app always meets that. A Data Center site must have a public https base URL.