Build & Test
Build & Test (http://<viewer>:8089/build.html) builds a branch of your app and tests the result on the devices. The build runs on the build plugin's own host — a Mac builds Android and iOS, a Linux host Android only — never on the viewer. MonkeyTester never talks to a code host itself: a build plugin fetches the branch from Gitea or GitHub, runs the app repo's .monkeytester/build-<platform>.sh scripts on its own host and uploads the apps back to the viewer, so the run attaches to the build.
The pipeline
Build & Test started in the viewer (project + branch + platforms + cases)
│ viewer POST /builds → build plugin (build-local, :8094)
▼
plugin fetches the branch (Gitea or GitHub, read-only token)
│ runs .monkeytester/build-android.sh + build-ios.sh on ITS OWN host
▼
Mac builds debug APK + signed device IPA · a Linux host builds APK only
│ the viewer's ci/submit.py --no-wait: one upload, app + every mt-tests/<case>/
▼
viewer POST /api/run-test (build_request = the build's id) → ONE run: every case × every phone
│ rows read "case / test", device switcher per test
▼
GET /api/builds/<id> → success / failure / cancelled (run page: passed / failed)
Building needs no workflow file in your app repo. Uploading to the viewer needs the CI token (see below). The run is always accepted and queued; when its turn comes it uses the Android phones and iPhones connected at that moment. If a platform has none it waits 5 minutes (MT_DEVICE_CONNECT_WAIT_SECS) and then fails with "Gave up after 300s waiting for an iPhone to connect".
The build plugin
A build plugin is a separate service that implements BUILD_PLUGIN_API.md (in the MonkeyTester repo): the viewer asks it for a repo's branches and test cases and to start a build; it holds the code host's address and a read-only token, which the viewer never sees.
| Plugin | Repo | Default port | What it does |
|---|---|---|---|
build-local | MonkeyTester-Plugin-Build-Local | 8094 | Fetches the code from Gitea or GitHub and builds it on its own host: Android and iOS on a Mac, Android only on Linux |
Any other build system can be connected by a plugin that implements the same contract. A plugin reports its live state from an open GET /health: its code host (kind: gitea or github), the platforms its host can build (detected at start: Xcode → ios, an Android SDK → android), the recipe paths and the capabilities it supports (logs, cancel).
Gitea or GitHub — your code host
The plugin reads and fetches the branch from the code host you configure — Gitea or GitHub — so nothing in the viewer or its docs assumes which host holds your app repo: the kind, URL and read-only token live in the plugin's own config (mode 0600, never returned by any endpoint). For GitHub Enterprise Server the code host URL is the web address; the plugin derives the API base and the clone URL from it. Registering and configuring the plugin:
- Install and start the plugin where your app gets built (its README; it runs on Linux or macOS, with or without Nix). On a Mac it needs Xcode (iOS), the Android SDK and a JDK; a Linux host offers Android only (Android SDK + JDK).
- Add it in Settings → Plugins → Build Plugin: its address (e.g.
http://192.168.125.71:8094) and its pairing token — thePLUGIN_TOKENit was started with, mandatory whenever the plugin listens beyond loopback. The address is saved only when the plugin's/healthanswers the build plugin contract; the row then shows its code host, the user the token belongs to and the platforms it can build — Build & Test greys out a platform the plugin can't build. - Click Configure on the row and fill the panel: the code host, its URL, a read-only token and the viewer URL (prefilled with the address you are using). The plugin checks the token with the code host before it stores anything; a rejected token changes nothing. Read-only is enough: the plugin only reads the repo and fetches it with git.
- Gitea: code host URL = the site's own address (e.g.
http://192.168.125.70:3000), and an access token withread:repository(plusread:user) under Settings → Applications → Access tokens. - GitHub: code host URL
https://github.com(https://<host>for GitHub Enterprise Server), and a fine-grained token withContents: read+Metadata: read(or a classic token with thereposcope for private repos).
- Gitea: code host URL = the site's own address (e.g.
- Add your repos under Projects (Settings → Build & Test):
owner/repo, the plugin that builds it and the project's branch (the default branch unless you pick another). A repo belongs to one project, on one build plugin. Save Projects asks the plugin whether its token can read the repo and whether the branch exists. - Commit one build script per platform to the app repo at the paths the plugin names (see the app repo side). Settings name a missing one and link the plugin's example script; adjust the example for your app and commit it.
- The upload: the plugin uploads the built apps through the viewer's
GET /ci/submit.pywith the build's request id, so the run attaches to the build. An upload naming a build the viewer started is accepted once without credentials (see Upload).
The app repo side
Commit one script per platform at the paths the plugin reports in /health recipes: .monkeytester/build-android.sh and .monkeytester/build-ios.sh (GET /template?platform= returns the example scripts — download them from Settings and commit them to your repo). The plugin runs each with bash from the root of a clean checkout of the branch, with:
| Variable | Value |
|---|---|
MT_PLATFORM | android or ios |
MT_OUTPUT | where the script must write the app: a .apk (Android) or a signed .ipa (iOS) |
MT_BRANCH | the branch being built |
MT_CASES | comma-separated case names |
MT_REQUEST_ID | the viewer's build id |
Exit status 0 with a non-empty file at MT_OUTPUT is a successful build; anything else is a build error, reported with the script's last error: lines and its log. A platform that failed to build while another one built still ends the build as success: the failed platform is uploaded as a build error with its log, so its devices show every test Unavailable with View logs. IPA signing: the app's build script signs the IPA, and MonkeyTester only installs it; the provisioning profile must include the test iPhone's UDID (simulator builds can't install on an iPhone).
Build & Test (from the browser)
Start any branch's tests from http://<viewer>:8089/build.html: pick project, branch, platforms and cases; the viewer asks the project's plugin to build and follows the build to its run.
- Build: the viewer
POST /buildsto the plugin withplatforms,casesand itsrequest_id; the build states follow:pending → queued → in_progress → completedwith a conclusion ofsuccess(the apps were uploaded),failureorcancelled. Jobs map to platforms by job name (Android,iOS, plusUpload). - One build at a time: builds run in a FIFO queue on the plugin; queued or running builds can be cancelled (the running script's process group is terminated), and the build log is tail-able (
GET /builds/<ref>/log?offset=) — Build & Test shows both. - Attach: when the plugin uploads, the run attaches to the build; the build entry links its run, and the run page is the normal result page.
A project is one repo on one build plugin: each repo in the list gets its own run history and Test Variables, while devices and plugins are shared. Runs with no repo are Unassigned. The dashboard filters by project.
Upload
Every run starts from Build & Test: the viewer accepts an upload only when its build_request names a build it started (anything else is refused with "Runs start from Build & Test"). The plugin uploads with the viewer's ci/visual-test/submit.py, served at GET /ci/submit.py so it needs no checkout of the repo, run from the checkout's root:
curl -fsS "$MT_URL/ci/submit.py" -o vt_submit.py &&
python3 vt_submit.py --url "$MT_URL" \
--android-app app/build/outputs/apk/debug/app-debug.apk \
--ios-app build/monkeytester/app.ipa \
--tests-dir mt-tests --branch "$MT_BRANCH" --repo "$MT_REPO" \
--cases "$MT_CASES" --build-request "$MT_REQUEST_ID" --no-wait
--no-wait is what a build plugin uses: the script uploads, prints --- <run_id> started and exits 0 once the viewer accepted the upload (non-zero when it refused it); the viewer works out the test results itself. A single platform passes --app path/to/app.ipa --platform ios (or an .apk with android); a platform that failed to build passes --ios-build-error <message> plus --ios-build-log <path> (same for Android) instead of its app.
The CI token
Build plugins need no CI token: the viewer accepts an upload whose build_request names a build it started (and is still waiting for apps) once, without credentials. Anything else is refused with "Runs start from Build & Test".
The one exception is an app repo's own CI that uploads with submit.py and no build_request — that run belongs to no build and needs the CI token:
- Generate it in the viewer: signed in as an admin, open Settings → Configuration → CI token and click Generate new CI token. It is shown once; generating another replaces it.
- Store it in the CI as the
MT_CI_TOKENsecret.submit.pysends it asAuthorization: Bearer. - The viewer accepts the CI token only to start runs and read their results: it does not open the UI or Settings. An unknown
build_requestis refused even with the token.
An MT_CI_TOKEN left in the viewer's own environment is imported into Settings once, when Settings has none, and ignored after that. See Security → Setting up tokens.
Test case layout in the app repo
mt-tests/
SETUP.txt # suite order for multi-case runs (one case name per line)
onboarding/
INSTRUCTION.txt # MODE, CLEAR_DATA, REINSTALL_APP headers
01_eula_to_home.txt # the test itself: one step per line
snapshots/… # SNAPSHOT baselines per screen class
device-setup/
INSTRUCTION.txt # REINSTALL_APP: true → start from a reinstalled app
01_provision_from_home.txt
02_detail_and_unassociate.txt
- Every case folder needs an
INSTRUCTION.txtand at least one test.txt. Tests run in file-name order; the case order comes fromSETUP.txt(unlisted folders run after, in name order). - Every case keeps its own
INSTRUCTION.txt(MODE,CLEAR_DATA) and snapshot baselines. Files referenced with@file:<path>are relative to the case folder, must stay inside it, and upload automatically. - The upload puts every case folder into ONE run; a failed test cancels the rest of that device's tests.